Slashdot Mirror


Review:Java Servlet Programming

CowboyNeal has taken some time out of his busy schedule to review Java Servlet Programming, a new ORA book out, written by Jason Hunter with William Crawford. Full of tips to extend the usage of the servlets, click below for more informatiion. Java Servlet Programming author Jason Hunter & William Crawford pages publisher O'Reilly & Associates rating 8 reviewer CowboyNeal ISBN 1-56592-391-X summary O'Reilly is known for it's in-depth, tell-all approach to computer related topics. This book doesn't disappoint and features many different ways to use Java Servlets, many of which may not occur to the average CGI scripter. What's Good?

I used Java Servlets almost immediately after their release, and always liked the idea of platform-indepent scripts that could give one the same functionality as CGI scripts. It didn't take long for me to discover that servlets aren't limited to returning only web pages, but this book explores several options that one may not think of right off.

The examples given are of use in practical real-world situations, whether it's connecting to a database to generate pages, editing images on the fly, or writing applets that connect to servlets. After reading the examples, you can easily see where you could utilize the concepts in server-parsed web pages.

Having written countless web scripts in Perl, I was pleased to see all of the major concepts of web scripting covered within the context of servlets. Java Servlet Programming includes a JDBC primer, as well as sections on session tracking and security issues.

What's Bad?

Not much. Seriously, O'Reilly books make up a large part of my personal library because they don't disappoint. The entire Java series is full of great books, and this one continues the trend. If you don't know much Java, this book isn't going to hold your hand through it, as it assumes that you're fairly secure in your knowledge of Java, and that you're comfortable using objects in Java.

Who should buy this book?

If you like Java and think that everything should be written in it, including your web scripts, then this is the book for you. I would consider this the best reference for servlet programming to date, and it beats the hell out of the standard documentation. If you're thinking about brewing up a Java servlet, this is the reference you want.

If you want to buy this book, head over to Amazon.

Table of Contents

Preface

  1. Introduction
  2. HTTP Servlet Basics
  3. The Servlet Life Cycle
  4. Retrieving Information
  5. Sending HTML Information
  6. Sendind Multimedia Content
  7. Session Tracking
  8. Security
  9. Database Connectivity
  10. Applet-Servlet Communication
  11. Interservet Communication
  12. Internationalization
  13. Odds and Ends

Appendix A: Servlet API Quick Reference

Appendix B: HTTP Servlet API Quick Reference

Appendix C: HTTP Status Codes

Appendix D: Character Entities

Appendix E: Charsets

Index

41 comments

  1. Fundamentals of servlet design different than perl by Anonymous Coward · · Score: 0

    Java servlets are persistent, which lets you take a different approach to servlet design, see:

    this servlet design article.

  2. Setting it up by Anonymous Coward · · Score: 0

    Well, the Java Web Server runs on any platform with a Java VM, so you can run it on Linux if you want. Its nice, and easy to setup, but a bit slow once it gets some serious use.

    Servlet exec (don't have a url off hand) is considered the best servlet runner, like 3x the performance of JRun, at least from what I've heard. Still, I prefer a Java web server for servlets.

    Orion http://orion.evermind.net is a small, fast pure Java web server with Servlet 2.1 and JSP 0.92 support. I run it under NT and Linux, works like a charm, and is super fast. Its in beta right now, but I consider it stable enough for production use.

  3. Better than JSP by Anonymous Coward · · Score: 0
    WebMacro servlet framework, I find it simpler and clearer than JSP.

    GPL I think.

  4. www.webmacro.org by Anonymous Coward · · Score: 0
    WebMacro is a servlet framework that people may find useful.

    It uses introspection to allow dropping objects into a template. Much nicer than JSP.

    It's GPL.

  5. Setting it up by Anonymous Coward · · Score: 0

    You should really consider the JavaWebServer...
    I've been running it on a solaris box, a linux
    box and now the Mac OS X box... It's great.
    It automatically knows when servlets have changed
    (which Netscape Enterprise doesn't and needs
    rebooting all the time), is nicely integrated
    with the java language, and allows communication
    with other elements (if you have say CGI elements
    still hanging around). Plus, the integration with
    JSP is excellent. Go to java.sun.com and download
    a free copy for evaluation and try it out for 30
    days - plus it's relatively cheap (though not
    free)...

    just my $.02...
    peace. JOe...

  6. Setting it up by Anonymous Coward · · Score: 0

    I find that the Jigsaw server supports servlets very well indeed and is free. AND they give a very nice HOW TO with their server. I think that it
    it an excellent choice for hacking (don't know about hight performance) AND it runs fine on my
    imac
    linux box
    nt machine
    digital unix system on an alpha
    etc......

    And it was pretty easy after reading the instructions

    David R.

  7. Setting it up by Anonymous Coward · · Score: 0

    I forgot

    Jigsaw is from W3c
    so go to

    http://www.w3c.org

    david R

  8. GNU Servlets by Anonymous Coward · · Score: 0

    The book is very good! Also, if you're interested in checking out more on servlets, see http://www.coolservlets.com -- they have some pretty good open source servlets there.

  9. Is This Book Really Needed? by haizi_23 · · Score: 0

    that's just 'cause you're a brilliant, shining beacon in this world of dimly flickering bic lighters. i liked the book, and thought the info on embedding servlets requests in html pages and servlet chaining was helpful. i didn't immediately think of those uses on my own. but perhaps i am an idiot. : )

  10. EJB's ? by euroderf · · Score: 1
    Does the book cover the Servlet/EJB connection ?

    Can anyone poiint to good on-web references ?

  11. Is This Book Really Needed? by Aaron+M.+Renn · · Score: 1

    Do we really need a book on servlet programming? I've been using Java servlets (via the Apache jserv module) for sometime and they are quite simple to use. Plugging JDBC into it to access a database is pretty straightforward. I guess I just don't see that there is anything complicated enough to justify writing an entire book on it. Am I missing something?

  12. Has anyone else noticed... by gavinhall · · Score: 1

    Posted by The Mongolian Barbecue:

    that the Java logo looks like a cup of coffee with a large turd floating in the center of it?

  13. Bull Tinkle -- look in chapter 2, pp. 37-47 by jabbo · · Score: 1

    title says it all. GnuJSP for Apache-Jserv is at 0.99, the only thing left is for Sun to finalize the specification.

    Oh, and did I mention Cocoon? Stefano's "XSP" idea (XML Server Pages) is probably the direction where JSP is headed anyhow.

    --
    Remember that what's inside of you doesn't matter because nobody can see it.
  14. Depends on what you're doing by jabbo · · Score: 1
    There are a lot of clever hacks which Hunter shows how to do, and he's *not* a dull blade. You might want to leaf through it before shooting off -- things like image manipulation and security are in this book, and I found those to be quite helpful. Oh, and sessions. Sessions are tres cool.

    If you're a wizard then duh, it won't help you. In that case head on over to the cocoon website and think about contributing to the project. Show everyone what a stud you are and work with some really neat material at the same time.

    --
    Remember that what's inside of you doesn't matter because nobody can see it.
  15. The mighty mod_jserv by jabbo · · Score: 1

    Take a look at Using Apache-Jserv and persevere. It took me a little while to set things up in Linux, but now we have embedded Java and Perl interpreters and everyone's delighted.

    Also, I don't have to depend on an evil monolithic corporation for my server software this way.

    --
    Remember that what's inside of you doesn't matter because nobody can see it.
  16. Help with setting up Apache-Jserv (link) by jabbo · · Score: 1

    If you have trouble getting mod_jserv built and
    running, take a look at Ari Halberstadt's great
    guide to Using Apache-Jserv. It can save you time and frustration.

    You could also hire him. (heheheh)

    Finally, for Apache 1.3.4 and 1.3.6, save yourself some trouble by symlinking {APACHE_INSTALL}/bin to {APACHE_INSTALL}/sbin.

    --
    Remember that what's inside of you doesn't matter because nobody can see it.
  17. java web tools vs. ??? by Kyril · · Score: 1

    So far I like Zope. Python is clean and simple. The database interface is simple and orthogonal: you write SQL "methods" that incorporate the input parameters, controlling optional SQL just like you control optional HTML in the web pages. In the web pages, you can invoke a Python method, database method, or external code with the same syntax; this includes iterating over the results within the HTML page.

    I don't miss Perl's regexp engine at all, because I simply don't need to use it under Zope.

  18. Book Cover by XPulga · · Score: 1

    Hmmm... finally the book cover from ORA isn't an animal. Now on with the "Silverware Series". Guess there'll be some "The Final Guide To Fork'ing And Exec'ing" with a cute fork on the cover...nahhh

  19. WHat's JSP? by zipwow · · Score: 1

    Sounds good, what is it? I've been looking for a 'template' layout that is java-based, and open standards. I remember using a JHTML thing a long time ago, but don't know who made it.

    Zipwow

    --
    I don't know which is more depressing, that 2/3 didn't care enough to vote, or that 1/2 of those that did are crazy.
  20. Java in a Nutshell Book Cover by homebrewer · · Score: 1

    Yeah,

    It's got a Javan Tiger on it (believed to be extinct, last seen in 1972)

    Mark

  21. Setting it up by ragnar · · Score: 1

    No, the book doesn't provide much advice for setting up servlets, and they take the easy road out by doing development with Sun's Java Web Server. The book is geared toward the developer, but it doesn't help with building Jserv or any other engines.

    From personal experience, I tried for a long time (about 3 weeks with many rebuilds) to set up the Apache Jserv on Solaris with Apache 1.3.4 and could never get it to work. I was able to get Apache and JRun (from www.livesoftware.com) to work, but some things were flaky with the class loader.

    I'm not doing my testing with Sun's Web Server. Don't get me wrong, Apache rules. I would rather use Apache, but if you want to use Servlets with ease and get going without much headache, the Java Web Server is really quite good. It is a nice alternative if you can't get Jserv or JRun working right.

    --
    -- Solaris Central - http://w
  22. Excellent Book by ragnar · · Score: 1

    Just to echo the reviewer's thoughts... I just finished reading this book and I am *very* impressed. I don't plan on writing a cgi script again as long as I can use servlets. The book is probably the most thorough I've read about a specific Java topic.

    --
    -- Solaris Central - http://w
  23. EJB's ? by ragnar · · Score: 1

    There is a short section about how to use Servlets with Java Beans, however since the Enterprise Java Beans API isn't officially released they don't have specific info on that. The introspection examples with Java Beans are pretty good.

    --
    -- Solaris Central - http://w
  24. Setting it up by ragnar · · Score: 1

    You can also use IBM's websphere, although I haven't heard much about it. You can run Sun's Java WebServer on Linux or other Java 1.1.6 enabled systems, but Sun will only Support it on Solaris or NT. My experience with JWS is that it is a little slower than Apache (I haven't pushed it really hard though) but it is easy to set up. A caveat - I've been administering Apache servers for over two years, so I'm speaking from experience, not bellyaching about anything.

    The Java Web Server costs $300, and Apache is free. Consider the cost of JWS as a support cost in case you need it... which is rather cheap as support goes.

    --
    -- Solaris Central - http://w
  25. Book Cover by The+Cheez-Czar · · Score: 1

    Actually none of ORA's java series have animals, starting from Exploring Java 1st edition I believe.

    In addition all the Linux Book have cowboys, and I'm not sure what their travel books have

    --
    This Signature does Not Exist !! FNORD
  26. Ditto... by greg_barton · · Score: 1

    Book is one of the better O'Reilly books I've bought, and I've bought a good few. It has both variety and depth. The only thing that confused me was the cover. Aren't teapots supposed to be reserved for books on 3D graphics? :-)

  27. This book is great. by Mad+Browser · · Score: 1

    One of the best O'Reilly books. Awesome.

    --
    RateVegas.com - Vegas Reviews
  28. no JSP by eostrom · · Score: 1

    According to the book, JSP came along just before the book went to press. There are about five pages on JSP, but it serves only to convey the general idea, especially since Sun has since introduced a radically different version of the spec.

    JSP looks really cool; once a 1.0 spec comes along, I'll be excited to use it.

  29. Setting it up by hfcs · · Score: 1

    I've seen instructions (on blackdown.org, I think...) about getting Sun's JWS set up and running on other OSs. It' is 100% pure java - you know, write once, run anywhere. ;-)

    -Bill

  30. GenericServlet ??? by bozo_guy · · Score: 1

    In all of the online documentation concerning servlets, I've only been able to find material that covers the HTTPServlet. Does this book get into the GenericServlet in any depth as far as implementing/extending goes?

  31. java web tools vs. ??? by ivar · · Score: 1

    I've quickly gone through this book with a relatively simple project in mind, but with so many options I'm not sure which tools to invest my learning time in. On one hand, I know a little Java, and servlets seem relatively easy.. on the other hand there are things like perl and Zope (python) that seem popular. Anyone have any contructive comments from experience ?
    In case it matters, the intended project is a dynamic website with a database backend.

  32. Book Cover by Catsclaw · · Score: 1

    Actually, virtually all the ORA books in the Java series (with the notable exception of Java in a Nutshell) have pictures of objects on the cover, not animals.

    AWT has a can of paint, Distributed Computing has Tinkertoys, Security has a bird's nest with eggs in it. You can browse through them at . Kinda cool.

  33. Setting it up by Anakin · · Score: 1

    So my options are

    a solaris box running Suns Java WebServer
    a solaris or linux box runing apache and JRun
    a solaris or linux box runing apache and Jserv

    anything else?

  34. Setting it up by Anakin · · Score: 1

    Does this book have details on setting up the server end of Java Servlets? Is there a different book i should get for this purpose. Or is there a good website to goto to walk me through the entire process?

  35. Servlet Programming by Rickie · · Score: 1

    This excellent book is THE definitive guide to servlet programming. Jason Hunter succeeds in showing us that servlet technology goes well beyond simply "replacing cgi". The book's companion web site (http://www.servlet.com) is a must for anyone seriously interested in servlets. Thumb up for Jason

  36. Depends on what you're doing by jabbo · · Score: 2
    There are a lot of clever hacks which Hunter shows how to do, and he's *not* a dull blade. You might want to leaf through it before shooting off -- things like image manipulation and security are in this book, and I found those to be quite helpful. Oh, and sessions. Sessions are tres cool.


    If you're a wizard then duh, it won't help you. In that case head on over to the cocoon website and think about contributing to the project. Show everyone what a stud you are and work with some really neat material at the same time.

    --
    Remember that what's inside of you doesn't matter because nobody can see it.
  37. Great book by Augusto · · Score: 2

    Servlets are pretty cool and this book covers the subject perfectly.

    Oh , and I bought it for 9.95$ including shipping at www.fatbrain.com and using the FATBRAIN code (plus got a cool cap).

    [ but if you want to contribute to Ron, get it from amazon with the link provided above ]

    --

    - sigs are for wimps.
  38. no JSP by sporkboy · · Score: 2

    I found that JSP (Java Server Pages) when used in conjunction with Servlets often provided a good complement in cases where the HTML code is the bulk of the output and the code is just filling in a few places in the template. Some coverage of this would have been a service to the web development community. Plus, despite its bugs, JSP has ASP beat in that Java is 100x better for programming anything over 10 lines than VBScript.

  39. The Java Apache Project by sidewinder · · Score: 2


    If you interested in trying out servlets try

    http://java.apache.org/

  40. www.coolservlets.com by chetters · · Score: 2

    Hey-

    If you're interested in Servlets, check out this new site.
    www.coolservlets.com
    It is all about open-source servlets and they have a few packages available already!
    CHET OUT

  41. perl vs. java vs. python by jabbo · · Score: 3

    If you're a pro, and want to write code that could comfortably live in an algorithms book (eg. "executable pseudocode"), Python is The Way. But I never got PyApache to compile and I don't like using anything but Apache so I gave up on Zope (couldn't get it to work via pcgi with Apache).

    Then there's Perl. It's ugly and it WORKS. That's all there is to it. Do what you will, just don't let a newbie Perl hacker anywhere near a production mod_perl system or you will regret it.
    Perl is tightly integrated with the Apache API via mod_perl, so you can do damn near anything in Perl that you can in C. Like AOLServer and Tcl or Roxen and Pike, Perl and Apache are an item. For building up libraries of reusable functions and objects you create Perl modules, simple as that.

    Java servlets are like Scheme programs if you do them right. You get a bunch of beautifully polished classes (because it just takes too damn long to write crappy code in Java) that are ideal for reuse, if you prototyped and designed well. Sessions are great, and the servlet API makes them trivial to use. Servlets are much, much better (IMHO) for production systems that have been slapped together as prototypes in something like Perl or Python. (an interesting extension to this idea is using JPython to write servlets... haven't heard of any recent successes but you could try) And the Apache-Jserv project is a great community thing -- very dynamic, lots of great new ideas. But Java is a (manually) compiled, strongly typed language and a servlet usually takes more time to write than the equivalent one-shot Perl script.

    My boss likes writing servlets because he can't deal with Perl, but doesn't mind Java at all. I like prototyping in Perl because it's fast, but god damn it feels good to come up with an elegant class and stick it in our local project's .jar. People who hack on supercomputers and BSD guts invariably seem to love Python, but I would have trouble hooking up Python to Oracle as cleanly as we have done with Java and Perl (total abstraction from the database via JDBC and DBI). So go with what makes you happy, it'll keep you from burning out. And use ApacheDBI if you go with Perl. ;-)

    --
    Remember that what's inside of you doesn't matter because nobody can see it.