Saturday, June 21, 2008

What's Scope of JSP objects? How many types?


Scope of the JSP objects


Scope of a JSP object determines whether that is object is available to be used at a particular place in the application or not. There are four types of scopes available for JSP objects. These are:-

  • application - an object having this scope will be available to all the JSP pages belonging to the same web application. Example: implicit object 'application' has this scope.
  • session - an object having this scope will be available for all the JSP pages belonging to the same session in which this object was instantiated. Example: implicit object 'session' has this scope.
  • request - an object having this scope will be available to all the pages which are involved in serving the same request. Example: implicit object 'request' has this scope.
  • page - an object having this scope will be available only on that particular JSP page where it was instantiated. This is the default scope for any object created from within a JSP page and most of the implicit objects have this scope only including 'page', 'out', 'exception', 'config', 'pageContext', and 'response'. Read more about implicit objects in the article - Implicit Objects in JSP >>


We can easily figure out that the 'page' scope is the least visible and the 'application' scope is the most visible among all the scopes available for JSP objects ( page < request < session < application in terms of Visibility).



Share/Save/Bookmark


3 comments:

Anonymous said...

Thank you for writing this.

Anonymous said...

My spouse and I absolutely love your blog and find most of your post's to be precisely what I'm looking for. Does one offer guest writers to write content available for you? I wouldn't mind composing a post or elaborating on some of the subjects you write with regards to here. Again, awesome web site!
My web page > burberry headband nordstrom

Geek said...

Hi 'Anonymous', yep, you can send in your articles... if I find them suitable I'll publish them. And yeah, please send the articles with your name so I can mention that in the post.