Hi friends Why we will use JSP and not servlet.Because JSP pages are again compiled into servlet and produces the Out put. Why I will follow this indirect process in which scenario. What are advantages in JSP over servlet (Regarding performance)? regards Bidyut
There is essentially no performance difference between JSP and servlets, except the first time a JSP is referenced, when it is compiled to a servlet. After that there is only a tiny overhead in dispatching a JSP, as it checks whether it has changed since the last recompile. JSPs are best used when a synamic page has almost all static text, with a few small dynamic parts.
JSPs are a way to rapidly develop web pages, being the default web content. Hence the content type is implicitly set as text/html for you. Servlets can return any content type and are not limitted to text based content. For example a servlet could return a dynamic image based on the input params.
JSP's can help seperate the presentation from the logic by using beans. With servlets you will have long println statements to serve up the response. However I used servlets mostly any way. I used 1 JSP because it was all html, it only need one parameter passed to it to be included in the output. With servlets you have to shut down the server in order to change a servlet code, not so with JSP.
I feel in general JSPs are good if your static content is more than your dynamic content. If you find yourself writing more HTML then processing logic for a given page then consider converting your servlet to a JSP. I like servlets because they easily lend themselves to OOP and offer better control. Regarding performance, I think I read somewhere that the JspWriter was slightly more optimized compared to the servlet PrintWriter and hence *could* be faster.
A crude comparison: JSP ~driving with automatic transmission, Servlet ~ driving with a stick-shift. The later gives better control. The former is easier.