> -----Original Message-----
> From: Richard Yee [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 09, 2002 1:58 PM
> To: [EMAIL PROTECTED]
> Subject: Re: R: R: What are the advantages of the servlets and JSP
> pages?
>
>
> Luca,
> First of all, let me say that this, along with your other question on
> PAGING RESULT SETS (hint: use those key words to search the
> archives) have
> all been covered many, many times on this list and the
> answers can be found
> more quickly and efficiently by searching the archives.
>
> That being said, then to your first question, "What are the
> advantages of
> servlets over JSP pages?", the answer is that it is often a
> design choice
> to use servlets over JSP pages when:
>
>   1) you don't have to output a page that is rendered in a
> browser, but
> instead need to have a lot of processing logic. A front controller is
> usually implemented as a servlet rather than a JSP. If you
> don't know what
> that is, do a search on it and you should find plenty of results. The
> reasoning behind this is that the JSP is geared towards
> outputting HTML or
> XML. If you have lots of code in it, it is hard to read.

  No it is not always hard to read. All depends on your organization. Just
as a servlet may also be hard to read if it is not well organized.

> 2) Servlets can be used to output binary data such as JPEG,
> GIF, and PDF
> files. The JSP has an implicit writer, out, that can only
> output text, not
> binary data.


  Not exactly. JSP was intended to output text, but may be used for binary
as well. Just use response.getServletOutputStream. Using that I've made
myself a JSP that outputs PDF, for example.


> 3) In a servlet, you have a bit more control over the form methods you
> process. You can selectively process either of the POST or
> the GET methods
> as opposed to the JSP which handles both by default. You can
> also handle
> the Delete, Options, Put, and Trace HTTP operations where you
> can't in a JSP.

  Never used Delete, Options, Put or Trace. So I cannot opinion on that. But
even though I have an opinion: I don't think they are really needed...


> 4) If your requirements dictate that you use the
> SingleThreadModel, you
> must use a Servlet because you can't do it in a JSP.

  Sure you can. That's what the <%@ page isThreadSafe="true | false" %>
directive is for!


>
> To answer your question about paging result sets, if you are
> using JSP, you
> can use any of a number of custom tag to do the work for you.
> http://jsptags.com/tags/navigation/pager/.
>
> Regards,
>
> Richard
>


  Actually you may use either Servlet or JSP to do most things. Which one to
choose? Well... depends on what will be made and organization and... TASTE.
The best way to discover is to obtain some experience. Try doing something
on both and you will see where you feel it better.

   []'s,

   Rodrigo.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to