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
 
----- Original Message -----
Sent: Thursday, October 07, 1999 3:52 AM
Subject: Servlets or JSP "that is the question"

Hi my friends. I am a new subscriptor to this list.
 
First of all, sorry if my english isn't good enough.
 
The question is that I was wondering if someone could explain me what is the advantage of using
servlets and jsp together when developing internet applications, if the role of the servlet can be
supplied with a bean into a jsp.
 
I am analizing a new internet application, and I have realized that the only reason for using a servlet
is checking users validity into a session, and so on, things that can be done with a bean into a jsp.
 
Are jsp's a substitution for servlets or a complement instead?
 
Thanks in advance.
 
-------------------------------------------------
Daniel Macho Ortiz
Analista Programador
Dep. Laboratorio.
FIHOCA
Tlf: (93) 410.90.00 Ext. 508
e-mail: [EMAIL PROTECTED]
-------------------------------------------------

Reply via email to