|
They actually complement each other
quite nicely. A common design goal when developing web applications
is to avoid putting a lot of programming code (e.g. scripting ala JSP) in
your HTML(or .jsp) files (since it's harder to maintain, the code is
less likely to be reusable, etc.) and to avoid putting a lot HTML into your code
(e.g. out.println("<br> <B>Hello "+user.name+"</B>
<br>"); ). One of the reasons for this is that ideally you'd
like an HTML-guy to be able to change the layout of pages (or add pages, etc.)
on your website without having to know
Java and you'd like your java-programmer-guy to not
have to be an HTML-expert. I, as a Java Programmer, hate doing HTML and I
suck at graphic design so I like this approach for selfish reasons as
well. :)
So.... One way to achieve this is to write
servlets that do most of the request processing (e.g. as the ACTION target
of FORMs), add any necessary beans into the session, and then forward to an
appropriate JSP. Using <useBean...> to create beans within JSP's is
fine for simple beans but when you need beans that take construction
parameters or have to come from a database you have to put code in your JSP
to do that which, to me, is ugly. If I find myself putting a lot of code
in a JSP I try to determine if a servlet/jsp combo would be better.
Hope that helps,
Brien Voorhees
|
- Servlets or JSP "that is the question" Daniel Macho
- Re: Servlets or JSP "that is the question" John Anderson
- Brien Voorhees
