Hi,


> he 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\">");
>

There are html wrapper classes available (eg. htmlKona) that u can use to make it
more pleasant than the above. These do it in an object way, and it is easier to
keep track, debug, and, wonder of wonders, make changes to the presentation.

>
> 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.
>

This appears to be the more worthwhile reason. However, one has to accept it with a
pinch of salt.

I suppose the general idea is that you output your data to a generally accepted
format that can be understood (deciphered) by using standard available templates.
This output is then picked up by the presenter's program which applies these
templates to convert it to an HTML, PDF, etc. respectively.
(Please correct me if I've got it wrong !)

Now, how JSP helps in achieving this, is what beats me. Probably, in its current
form, it does not do it. Is the "taglib" directive meant to achieve this (probably
in the future) ? Something like <pdf:heading ....  />, <pdf:font size="12" .....>,
etc.

Could somebody elaborate ?

- Uddipan.

>
> 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

===========================================================================
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