File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlet best practices Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet best practices" Watch "Servlet best practices" New topic

Servlet best practices

Simon Good
Ranch Hand

Joined: Sep 19, 2002
Posts: 30
I've been given the unfortunate task of building a web site using servlets and a third party templating technology. That means JSPs are strictly out. Can anyone point me in the direction of some documentation on building java apps using purely servlets. There must be some best practices for this kind of thing.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Turn that frown upside down!! hehe.

Not being able to use JSPs is not the end of the world. If the 3rd party templating stuff is Velocity, then I'd start to smile. I've used it before a few times and have loved it always, and haven't missed JSP at all. The rest of this post assumes that by "JSPs are strictly out" you mean "I have a presentation layer OTHER THAN servlets" (that being: the templating technology you spoke of).

As for tutorials on model-2, I admit I've always been dismayed by the utter *lack* of good ones. The one tutorial on servlets, and JUST sevlets on is from 1996. Everyone always seems so gung-ho about talking about Model-2, but then when it comes time to do some samples, they always run back to doing JSP pages. That is: they ignore their own advice.

A much more recent one is the J2EE tutorial,
found here but this is much more than just servlets, and it contains a lot of implementation details regarding the RI J2EE server. Let's not even go there!

Other links I've found, with varying usefullness:
Very dated, ignore everything that makes mention of a jswdk, or that makes you go "Well DUH!" (like the last sentence in the 'So What's Wrong With Servlets?' section)
This is an entire chapter from Professional JSP 2nd Edition on using JSP/Servlets/Beans in a MVC (model2) architecture. Decent reading, just translate any of their JSP stuff into your templating technology.
That last one seems more up your alley, and has the added benefit of being recent!

And no discussion of this sort should leave out a mention of frameworks.
struts While struts has a JSP taglib and recommends JSP for view layer.. in reading their docs you'll probably gather a lot of good information on model2.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

one last one "from the source"
I agree. Here's the link:
subject: Servlet best practices
It's not a secret anymore!