4 JSP Implicit Methods

Infact, I don’t think that there are any implicit methods in JSP but I know there are 9 implicit objects. The methods of these 9 implicit objects and classes readily available for the Programmer, I call them, as JSP implicit methods. I concentrate especially on 4 interfaces because the methods of these interfaces are useful to communicate data in between all JSPs of a Web application.

The importance of these 4 JSP Implicit Methods of request, session, application and pageContext is that they can transfer information between JSP pages and Servlets as an easy data-sharing mechanism. The standard methods provided by these objects are very helpful to set and get the values.

Following is the table of 4 JSP Implicit Methods for storing and retrieving attribute values.
Method Description
setAttribute(String key, Object value) Known as set attribute which associates a value with a key. Returns void.
getAttributeNames() Returns the keys of all attributes set with session object. Returns an object of Enumeration.
getAttribute(String key) Known as get attribute which returns the value associated with the key. Returns an object of Object class.
removeAttribute(String key) Removes the attribute value set with the key earlier. Returns void.

The set attribute methods take data as key/value pairs where key is java.lang.String object and value is an object of java.lang.Object.

These JSP Implicit Methods are used in implicit objects of application and session.

1 thought on “4 JSP Implicit Methods”

  1. Very short and easy post to follow.

    Sir, please see if adding namesof respective classes/interfaces of these methods to this table is good. Also, please create a post showing difference between attributes and parameters.

Leave a Comment

Your email address will not be published.