Open In App

Classes of JSP API

JSP API is a set of classes and interfaces that can be used to make a JSP page. These classes and interfaces are contained in the javax servlet.jsp packages. A portion of the classes characterized in the javax. servlet.jsp packages are: 
 

  1. Error Data
  2. JSP Writer
  3. Page Context

The Error Data Class: The error information class characterizes error data for error pages. You have to set the estimation of the page mandate, isErrorPage to be consistent with demonstrating that a page is an error page. The error information class expands the java.lang.Object class. A portion of the strategies characterized in the ErrorData that you can use in a JSP page is: 



  1. getRequestURL(): Returns the mentioned URL through String.
  2. getServletName(): Returns the name of the servlet conjured through String.
  3. getStatusCode(): Returns the status code of the blunder as a whole number.
  4. getThrowable(): Returns the Throwable special case that caused the mistake.

The JspWriter Class: In a JSP page to compose activity and layout information we can utilize JSPWriter class. The understood variable out gives the JSPWriter class object. The JSPWriter class broadens the java.io.Writer class. A portion of the techniques characterize in the JSPWriter class that you can use in a JSP page are: 
 

  1. clear(): Clears the substance of the cradle. The reasonable() technique tosses an IOException special case if the support is now cleared.
  2. close(): Closes and flushes the stream.
  3. flush(): Flushes the cradle stream. The flush() strategy flushes every one of the cradles in a chain of Writers and OutputStream. It tosses java.io.IOException special case on the off chance that you make a call to the compose() or flush() in the wake of shutting the stream.
  4. getBufferSize(): Return the size of the support utilized by the JSPWriter.
  5. print(): Prints the estimation of sort boolean, integer, character, long whole number, coasting point, twofold exactness gliding – point number, a variety of character, string, and item. The print() tosses the java.io.IOException exemption if any blunder happens while printing.
  6. println(): Prints an estimation of sort boolean, whole number, character, long whole number, drifting point, twofold exactness coasting point number, a variety of character, string, and article. The Println() tosses the java.io.IOException exemption if any blunder happens while printing.

The PageContext Class: The setting data is given by the PageContext class when the JSP innovation is utilized in the servlet condition. The PageContext class expands the JSPContext class. A PageContext occasion furnishes access to namespaces related to the JSP page. Some of the strategies characterized in the PageContext class are: 
 



  1. forward(): Redirects the current servlet demand and servlet reaction to another page. This strategy acknowledges the URL of an objective page as a contention.
  2. getPage(): Returns the present estimation of the page object.
  3. getRequest(): Returns the present estimation of the solicitation object. The servlet solicitation is the arrival kind of getRequest().
  4. getResponse(): Returns the present estimation of the reaction object. The return kind of the getResponse() technique is the servlet reaction.
  5. getServletConfig(): Returns the ServletConfig of the present page.
  6. getServletContext(): Returns the ServletContext of the present page.
  7. getSession(): The arrival kind of getSession() is HttpSession. It will restore the current PageContext.
  8. include(): Processes the current servlet demand and the reaction determined in the URL. The incorporate() technique accepts two contentions, a URL way and the flush estimation of boolean sort.

    Session Tracking in JSP: 
     

<input type = "hidden">
session.getValued("msg") 
Article Tags :