36. Sir, do you know about jsp application object

  • This implicit object represents the application to which the JSP belongs.
  •  JSPs are grouped into applications according to their URLs where the first directory name in a URL defines the application.
  • The application object contains methods that provide information about the JSP Container, support for logging plus utility methods for example translating a relative URL to an absolute path.
Servlet Class

javax.servlet.ServletContext

The following table summarises the most useful methods available to the application object.

Method Description
getAttribute(String objName) Returns the object named objName or returns null if the objName does not exist.
getAttributeNames() Returns an Enumeration containing the attribute names available within the application.
setAttribute(String objName, Object object) Stores the object with the given object name in this application.
removeAttribute(String objName) Removes the objName object from the application.
getMajorVersion() Returns the major version of the Servlet API for the JSP COntainer.
getServerInfo() Returns information about the JSP Container, typically, name and product version.
getResourceAsStream(Path) Translates the resource URL into an input stream for reading.
log(Message) Writes a text string to the JSP Containers default log file.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: