All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.servlet.jsp.package.html Maven / Gradle / Ivy

The newest version!







Classes and interfaces for the Core JSP 2.3 API.

The javax.servlet.jsp package contains a number of classes and interfaces that describe and define the contracts between a JSP page implementation class and the runtime environment provided for an instance of such a class by a conforming JSP container.

JSP Page Implementation Object Contract

This section describes the basic contract between a JSP Page implementation object and its container.

The main contract is defined by the classes {@link javax.servlet.jsp.JspPage} and {@link javax.servlet.jsp.HttpJspPage}. The {@link javax.servlet.jsp.JspFactory} class describes the mechanism to portably instantiate all needed runtime objects, and {@link javax.servlet.jsp.JspEngineInfo} provides basic information on the current JSP container. Class {@link javax.servlet.jsp.JspApplicationContext} stores application-scoped information relevant to JSP containers. It was added in JSP 2.1 to support the integration of the unified Expression Language.

None of these classes are intended to be used by JSP page authors; an example of how these classes may be used is included below.

Implicit Objects

The {@link javax.servlet.jsp.PageContext} object and the {@link javax.servlet.jsp.JspWriter} are available by default as implicit objects.

Exceptions

The {@link javax.servlet.jsp.JspException} class is the base class for all JSP exceptions. The {@link javax.servlet.jsp.JspTagException} and {@link javax.servlet.jsp.SkipPageException} exceptions are used by the tag extension mechanism.

For JSP error pages, the {@link javax.servlet.jsp.ErrorData} class encapsulates information about the error.

An Implementation Example

An instance of an implementation dependent subclass of the {@link javax.servlet.jsp.PageContext} abstract base class can be created by a JSP implementation class at the beginning of it's _jspService() method via an implementation default {@link javax.servlet.jsp.JspFactory}.

Here is one example of how to use these classes

 public class foo implements Servlet {

 // ...

public void _jspService(HttpServletRequest request,
			HttpServletResponse response)
       throws IOException, ServletException {

    JspFactory  factory     = JspFactory.getDefaultFactory();
    PageContext pageContext = factory.getPageContext(
					this,
					request,
					response,
					null,  // errorPageURL
					false, // needsSession
					JspWriter.DEFAULT_BUFFER,
					true   // autoFlush
			        );

    // initialize implicit variables for scripting env ...

    HttpSession session = pageContext.getSession();
    JspWriter   out     = pageContext.getOut();
    Object      page    = this;

    try {
        // body of translated JSP here ...
    } catch (Exception e) {
        out.clear();
        pageContext.handlePageException(e);
    } finally {
        out.close();
	  factory.releasePageContext(pageContext);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy