Course details

JavaServer Pages often serve the same purpose as programs implemented using the Common Gateway Interface (CGI). But JSP offer several advantages in comparison with the CGI.

  • Performance is significantly better because JSP allows embedding Dynamic Elements in HTML Pages itself instead of having a separate CGI files.

  • JSP are always compiled before it's processed by the server unlike CGI/Perl which requires the server to load an interpreter and the target script each time the page is requested.

  • JavaServer Pages are built on top of the Java Servlets API, so like Servlets, JSP also has access to all the powerful Enterprise Java APIs, including JDBC, JNDI, EJB, JAXP etc.

  • JSP pages can be used in combination with servlets that handle the business logic, the model supported by Java servlet template engines.

Finally, JSP is an integral part of Java EE, a complete platform for enterprise class applications. This means that JSP can play a part in the simplest applications to the most complex and demanding.

Advantages of JSP:

  • vs. Active Server Pages (ASP)
  • vs. Pure Servlets
  • vs. Server-Side Includes (SSI)
  • vs. JavaScript
  • vs. Static HTML

JSP Implicit Objects are the Java objects that the JSP Container makes available to developers in each page and developer can call them directly without being explicitly declared. JSP Implicit Objects are also called pre-defined variables.

JSP supports nine Implicit Objects:

  • request
  • response
  • out
  • session
  • application
  • config
  • pageContext
  • page
  • Exception

The out implicit object is an instance of a javax.servlet.jsp.JspWriter object and is used to send content in a response.

The initial JspWriter object is instantiated differently depending on whether the page is buffered or not. Buffering can be easily turned off by using the buffered='false' attribute of the page directive.

Following are the important methods which we would use to write boolean char, int, double, object, String etc.

Method:

  • out.print(dataType dt)
  • out.println(dataType dt)
  • out.flush()

Servlet and JSP Filters are Java classes that can be used in Servlet and JSP Programming for the following purposes:

  • To intercept requests from a client before they access a resource at back end.
  • To manipulate responses from server before they are sent back to the client.

There are various types of filters suggested by the specifications:

  • Authentication Filters.
  • Data compression Filters
  • Encryption Filters .
  • Filters that trigger resource access events.
  • Image Conversion Filters .
  • Logging and Auditing Filters.
  • MIME-TYPE Chain Filters.
  • Tokenizing Filters .
  • XSL/T Filters That Transform XML Content.

Servlet Filter Methods:

A filter is simply a Java class that implements the javax.servlet.Filter interface. The javax.servlet.Filter interface defines three methods:

  • public void doFilter (ServletRequest, ServletResponse, FilterChain)
  • public void init(FilterConfig filterConfig)
  • public void destroy()

Reading Form Data using JSP

JSP handles form data parsing automatically using the following methods depending on the situation:

  • getParameter()
  • getParameterValues()
  • getParameterNames()
  • getInputStream()
Updated on 26 May, 2016

About Geek Zone Training Center

We’re a group of learning enthusiasts and hardcore techies; in a time where technology is becoming a major part of our lives all in a single click or touch. We seek to be more than just consumers of technology; we’re looking for teaching and developing Egyptian talents to compete with the national and international market

See all Geek Zone Training Center courses
Are you from Geek Zone Training Center ? Claim your course!
Courses you can instantly connect with... Do an online course on Programming starting now. See all courses

Is this the right course for you?

Rate this page

Didn't find what you were looking for ?

or