Introduction to Java Server Pages

What is JSP

Java server pages is the J2EE technology for generating dynamic web content. JSP specification is provided buy sun micro systems for vendors to implement. JSP specification is based on the functionality provided by Servlet specification. JSP specification provides more convenient web page authoring framework than Servlet and simplifies the creation and management of dynamic web content. JSP provides template-based approach to content generation. JSP pages are textual documents containing HTML, XHTML, or XML markup with embedded Java code and custom JSP tags.

How does JSP differs from Servlets

From the developers perspective Servlets are pure java programs with class and method definitions whereas a JSP page is much like a text document or web page. With servlets developer must write java code to output the entire markup, on the other hand a JSP page can be designed like a static web page. JSP separates static content from dynamic content and Java beans and/or custom JSP tags are used to generate dynamic portion of the web page. Servlets are well suited for handling client request and executing application logic whereas JSP pages are well suited as views.

Every JSP is a Servlet

Every JSP page is compiled into a servlet by JSP engine. The first time the JSP engine receives the request for a JSP, it converts the JSP page into a servlet and than compiles this servlet, it is called the translation phase. If needed JSP pages can also be precompiled. Once the JSP page is compiled into a servlet, all the subsequent requests will be handled by the compiled servlet class. If you modify the source code of the JSP file, container automatically detects the changes and recompile the JSP page the next time that JSP page is requested.

Following figure explains the JSP translation process.
@TODO Insert image

Note: If the JSP pages are translated on demand when the container receives the request for an untranslated JSP page than there will be a slow response for the first time any JSP page is requested. On other hand container may choose to translate the JSP pages at deployment time in that case the first request for any JSP page will take the normal time.

Recommended

Read java hosting reviews at webhostingsearch, to ensure that you get a quality web host to host your JSP based website.