Meaningless Drivel is fun!*
The moose likes JSP and the fly likes implicit objects in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "implicit objects in jsp" Watch "implicit objects in jsp" New topic
Author

implicit objects in jsp

nirali shah
Greenhorn

Joined: Apr 16, 2009
Posts: 24
There are implicit objects like request, response, session, out, Page Context etc available for use.
These objects can be used directly and instantiation takes place automatically. If a method by the same name is existing in both the classes, which one would be invoked eg session.getAttribute(String name) is in Session and PageContext both the classes. session is reference which can be used with any object. So in this situation when
${session.getAttribute("name")} is used in jsp, which class will be instantiated , Session or PageContext ? session is reference or classname ? I tend to assume that session is referance name in here because it starts with lower case "s". Classname starts with uppercase "S". If session is classname in here, why is it starting with lower case which is contrary to convention.

Please explain this in detail , how does instantiation of implicit objects work.

thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

Implicit objects are instances, not classes.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

And they're already instantiated by the time control gets to your JSP.
nirali shah
Greenhorn

Joined: Apr 16, 2009
Posts: 24
Even an instance has to be created.

Session session = new Session();

this creates an instance of Session object and session is the reference for this object. After this we can access properties of Session. If Session and PageContext have a method by the same name, then how to access it ? How would I know, an instance of Session is referred by what name and an instance of PageContext is referred by what name ?

As David replied that these objects are alredy instantiated. What reference is pointing to these instances ?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

session and pageContext, respectively.
 
wood burning stoves
 
subject: implicit objects in jsp