If you've taken a look at J2EE and JavaServer Pages technology, and want to examine JSP more closely, you've come to the right place. This article is the second of two parts, excerpted from chapter three of Beginning J2EE 1.4 From Novice to Professional, written by James L. Weaver, Kevin Mukhar, and Jim Crume (Apress, 2004; ISBN: 1590593413).
JavaServer Pages, conclusion - The config Object (Page 2 of 7 )
This object is used to obtain JSP-specific init parameters. These initialization parameters are set in the deployment descriptor, but are specific to a single page. JSP init parameters are set in the <servlet> element of the deployment descriptor. This is because the page implementation class of the JSP (the Java class which is compiled from the JSP page) is a servlet class. The <servlet> element with the <init-param> element will look like this:
See Chapter 5 for more information on how to use the <servlet> element.
If JSP initialization parameters are defined in the deployment descriptor, you can access them using:
The exception Object
This implicit object is only available within error pages. It is a reference to the java.lang.Throwable object that caused the server to call the error page.
The application Object
This object represents the web application environment. You will use this object to get application-level configuration parameters. Within the deployment descriptor, you can set application parameters using this element:
Objects that are created as part of a JSP have a certain scope, or lifetime. That scope varies with the object. In some cases, such as the implicit objects, the scope is set and cannot be changed. With other objects (JavaBeans for example), you can set the scope of the object. Valid scopes are page, request, session, and application.
page Page scope is the most restrictive. With page scope, the object is only accessible within the page in which it is defined. JavaBeans created with page scope and objects created by scriptlets are thread-safe. (Recall, though, that Java objects created by declaration elements are not thread-safe.)
request With request scope, objects are available for the life of the specific request. This means that the object is available within the page in which it is created, and within pages to which the request is forwarded or included. Objects with request scope are thread-safe. Only the execution thread for a particular request can access these objects.
session Objects with session scope are available to all application components that participate in the clients session. These objects are not thread-safe. If multiple requests could use the same session object at the same time, you must synchronize access to that object.
applicationThis is the least restrictive scope. Objects that are created with application scope are available to the entire application for the life of the application. These objects are not thread-safe and access to them must be synchronized if there is a chance that multiple requests will attempt to change the object at the same time.