The main reason is because if you just use servlets, you aren't separating
the business logic from the presentation.   With a JSP you can use mostly
HTML with little bits of dynamic content in the page. If you use a servlet,
you have to hand code the HTML and do things like escape quotes and all
sorts of nasty stuff.   Just look at the .java file that is created from a
JSP and you'll quickly realize that hard coding HTML into servlets is not
fun at all, particularly when you have to make changes.   It's extremely
error prone and tedious to find and make changes to 500 lines that like
this:

out.println("<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR><TD
VALIGN=\"BOTTOM\" COLSPAN=\"2\" NOWRAP><TABLE BORDER=\"0\" CELLSPACING=\"0\"
CELLPADDING=\"0\"><TR><TD WIDTH=\"105\"></TD><TD ALIGN=\"CENTER\">");

Another often overlooked reason for separating business logic from
presentation is that you don't have to output to HTML.  It could be XML,
PDF, or another EDI format.   The servlet API doesn't even require that your
output be of HTTP for that matter.

Mike

----------
>From: Khurram Mahmood <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: JSP vs. Servlets?
>Date: Thu, Oct 14, 1999, 10:26 AM
>

> Hi,
>
> So far I havent been able to find any particular advantage of using JSP
> instead of servlets. I don't understand why to have JSP when you can have
> servlets? I know that JSP files can be compiled into servlets but then why
> to have them in the first place???
>
> Could you please help me with this?
>
> Thanks.
>
> KM

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to