09-08-2012, 12:15 PM
INTRODUCTION JSP
JSP.ppt (Size: 235 KB / Downloads: 56)
Introduction
Java Server Pages (JSP)
is a Java technology that serves dynamically generated web pages based on HTML, XML, or other document types.
Released in 1999 as Sun's answer to ASP and PHP
JSP is web resource with embedded java code.
Java code is preprocessed in server side.
Application server converts entire page to HTML and resolves all dynamic content before sending page to client browser.
JSP does not replace applets or Java scripts.
JSP is built on top of servlets, but JSP is much easier to program
It uses a Java programming language-based scripting language .
What can JSP do
Can make platform independent dynamic web pages
syntax is a mix of scriptlet elements and markup.
Markup is typically standard HTML or XML
Scriptlet elements are delimited blocks of Java code
JSP pages must be compiled to Java bytecode classes before they can be executed
Getting data from the user
Connecting to databases
Handling cookies
JSP pages may invoke EJB or Java Beans to perform further processing.
Simplifies the process of creating pages by separating web presentation from web content.
How the JSP program works
Client requests for a web page with ".jsp“. extension.
The Web Server fires up the JSP engine.
The JSP engine checks to see if the JSP file is new or changed.
If the JSP file has changed , it is converted it into a Java servlet (by JSP parser)
The JSP engine compiles the servlet (by standard Java compiler).
Servlet Engine executes the new Java servlet using the standard API.
Servlet’s output is transferred by Web Server as a http response.
If the JSP file has not changed then
Servlet Engine executes the existing Java servlet using the standard API.
Servlet’s output is transferred by Web Server as a http response.
Optional attributes of page directive
autoFlush - is used to specify whether or not to automatically flush out the output buffer when it is full.
isThreadSafe - is used to set whether the generated Servlet handles multiple requests or single requests, depending on the set value of true or false
Info - attribute to place the information or documentation for a page.
errorPage - wants to place errors in a different page then the URL to the error page can be mentioned in this attribute as errorPage.
IsErrorPage - attribute is used to specify whether or not a JSP page displays an error page by setting the value as true or false. By default, the value is set to false
contentType - attribute is used to set the mime type and character set of the JSP.