This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes implicit jsp objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "implicit jsp objects" Watch "implicit jsp objects" New topic
Author

implicit jsp objects

Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
hi
Implicit objects are not available inside jspInit() or jspDestroy() method.That means implicit objects are available in _jspService() method only.
is it so?
Thanks
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

yes. Implicit objects are available only in _jspService() method. In JSP, you can access those in scriplets, expressions but not in declaration(because it goes out side _jspService method on converted servlet).


hth,


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
Elan Ram
Ranch Hand

Joined: Dec 14, 2006
Posts: 40
Hey we can access implicit object inside jspInit()/jspDestroy() method.

Eg
config implicit object.


Thanks and regards,
Elan
Rohitt Vermaa
Ranch Hand

Joined: Oct 12, 2006
Posts: 232
The implicit objects are the local variables inside the _jspService method. So jspInit() and jspDestroy() have no access to it.


SCJP ,SCWCD
Abhijeet Mahule
Greenhorn

Joined: Oct 17, 2006
Posts: 11
Hi All,
Just to throw more light on this topic.

The _jspService() method is responsible for producing all the implicit objects (session, config, application, config etc). This is done at the very beginning of the _jspService() method.

An example of how the _jspService() method in a converted servlet looks like:

public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {

JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;


try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
}
....
....
}

Thus any scriptlet or expression is able to use these local implicit objects as they are initialized at the beginning of _jspService() only.

The statement that "Implicit objects cannot be used outside _jspService method" is very much true due to their local nature.


Stay connected, Remain beautiful
Abhijeet Mahule
SCJP 1.4, SCWCD 1.4
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
well said abhijeet ! and i like your signature ...

Stay connected, be beautiful


SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: implicit jsp objects
 
Similar Threads
HttpSession in JSF
implicit object in Tag file
JSP Implicit objects
tag files and implicit objects
Implicit Objects available in Tag Files