online tutorials, website development, web application development

   

JSP

JSP - JavaServer Pages technology provides a simplified, fast way to create dynamic web content.
  1. JSP is a high level extension of servlet and it enable the developers to embed java code in HTML pages.
  2. JSP files are finally compiled into a servlet by the jsp engine

JSP Tags
  • Directives
  • Declarations
  • Expressions
  • Scriplets
Directives
Syntax : <%@ directive attribute = "value" %>
Definitions
  • Page : Page is used to provide the information about it
    (e.g) <%@ page language = "java" %>
  • Include : Include is used to include a file in the JSP page
    (e.g) <% @ include file= "/filename.jsp"%>
  • Taglib : Taglib is used to use the custom tags in the JSP pages
    (e.g) <% @taglib url = "tlds/taglib.tld" prefix ="mytag" %>
Declarations:
Syntax : <%! int a; %>

Expressions:
Syntax : <%= expression %>

Scriplets:
Syntax : <% Java Code %>

JSP Implicit Objects:
Objects in JSP can be created either implicitly by using directives or explicitly by using standard actions or directly by declaring them with in scriplets.

Implicit Object Class Description
Application javax.servlet.servletcontext The application object defines a web application. Usually it is the application in the current web content
Config javax.servlet.servletconfig Represents the object of a servlet config class
Exception java.lang.throwable Represents the throwable exception in a JSP page
Out javax.servlet.jsp.jspwriter Represents an object of JSP writer to send response to the client. JSP Writer extends the print writer class and is used by JSP pages to send client responses.
Page java.lang.object Represents the current instance of the JSP page that in turn is used to refer to the current instance of the generated servlet.
Session javax.servlet.http.HttpSession Represents a session object of Http Session interface
Response javax.servlet.http.HttpServlet Response Represents a response object of Http Servlet Response that is used to send an HTML output to the client.
Request javax.servlet.http.HttpServlet Request Represents a request object of Http Servlet Request. It is used to retrive data submitted along with a request.
Page Context javax.servlet.jsp.PageContext Represents the page context for a JSP page.