Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

implicit objects in jsp

 
nirali shah
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64200
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Implicit objects are instances, not classes.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And they're already instantiated by the time control gets to your JSP.
 
nirali shah
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64200
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
session and pageContext, respectively.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic