Discussions

Web tier: servlets, JSP, Web frameworks: JSP Vs Servlets?

  1. JSP Vs Servlets? (3 messages)

    Can anybody tell the advantages of JSP over Servlets?

    Threaded Messages (3)

  2. JSP Vs Servlets?[ Go to top ]

    From a coding point of view if we want to send text to back to a response

    The Servlet way is:
    response.write("<p>hello</P>");

    The JSP is:
    <p>hello</P>

    I have found that for puming information to clients without manipulating it JSP is best, but for doing serious computations on data before (ie business logic) sending the respone back Servlets are best.

    This allows for isolation of business logic from presentation logic.

    So from a design perspecitve a Servlet/Bean called from a JSP might be a good approach.

    Hope this helps....

    James...
  3. JSP Vs Servlets?[ Go to top ]

    JSPs are compiled to servlets, effectively allowing you to produce a servlet by just writing the HTML page, without knowing Java. Of course, in practice, to get anything serious done, you need to use some server-side code in there...

    If you write servlets, you need to know Java to write the servlet body, and HTML to write the output.

    The real advantage of JSP is the use of special tags that allow you to call Java beans directly, and the ability to produce your own custom tags (in Java) to do stuff that you can't do with a single call to a Java bean (e.g. inserting a list of items into the HTML, which needs a loop construct).

    The idea of JSP is that a development house can put a team of specialists onto developing their web applications. A HTML web page writer/designer can write the JSP without knowing Java, using beans and custom tags written by Java experts.

    Unfortunately, custom tags are a bit tedious to produce, and for very simple stuff, like simple loops, or stuff that's unlikely to get re-used, they can seem like overkill.

    So JSP allows you to put real Java directly into the HTML inside special tags.

    All this Java code will be executed before the HTML is sent to the client, and is generally used to modify the HTML page.

    Ironically, individuals producing JSP applications on their own often end up with a JSP containing HTML, JavaScript, and Java all in the one file, which can be a little confusing, especially with all the JSP tags scattered around!

    Dave
  4. JSP Vs Servlets?[ Go to top ]

    Just go through these links I found the same question with answer on another site and also you can read more about JSP on following links

    http://www.coderanch.com/t/201735/Performance/java/Servlets-Vs-JSP

    http://www.alachisoft.com/ncache/improve-javaserverpages-performance.html