Intro to JavaServer Pages: Utilize the implicit object set

Learn how to fully use the implicit object set by understanding the Java Servlet API.

By John Zukowski

The last of the JSP syntax-related elements are something called implicit objects. Within JSP scriptlets, you have access to these implicit objects to interact with the executing servlet environment for the JSP page. Much of the access to the implicit objects should be minimized. However, there are instances in which access is acceptable. To fully utilize the implicit object set requires an understanding of the latest Java Servlet API.

The following table represents the set of implicit objects available to you.

Implicit Object Description
  requestThe client request, which includes parameters from GET/POST requests
  responseThe page's response back to the client
  pageContextThe attributes of the page are managed here
  sessionThe session associated with the request
  applicationThe context in which the servlet is running
  outThe output stream used to send the response
  configThe servlet configuration object
  pageThe JSP page itself
  exceptionFor error pages, the uncaught exception

So, what are all these for, and how do you use them? Well, basically, within your scriptlets you can use them to access the servlet executing the JSP code. Without going into too many details of the Servlet API, let's examine some of the things you can do with them:

  • Instead of using an expression, you can directly access the implicit out object to print something to the response:
    <% out.println("Hello"); %>.
  • Instead of sending a parameter directly to a JavaBean, you can get the parameter value from the request object:
    <% String name=request.getParameter("name"); out.println(name); %>.

As you develop more with JSP, if you create JavaBeans or find yourself putting too much Java source code into your JSP files, you'll need to create supporting Java classes, which encourages reuse and decreases JSP page translation time. When you need to create Java class files, you must:

  1. Add the JDSWK installation \bin directory to your PATH. In yourautoexec.bat file's PATH line, add C:\1.2.2\bin; to the end of that line.
  2. Copy the JAR file to the \jre\lib\ext directory with the command:
    copy c:\jswdk-1.0.1\lib\servlet.jar c:\jdk1.2.2\jre\lib\ext.
John Zukowski is a software guru and director of education at In addition, John is the author of several Java books and numerous Java-related technical articles.

Editor's Picks

Free Newsletters, In your Inbox