permaculture playing cards
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
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "implicit jsp objects" Watch "implicit jsp objects" New topic

implicit jsp objects

Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
Implicit objects are not available inside jspInit() or jspDestroy() method.That means implicit objects are available in _jspService() method only.
is it so?
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).


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />
Elan Ram
Ranch Hand

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

config implicit object.

Thanks and regards,
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.

Abhijeet Mahule

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, 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();
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.
I agree. Here's the link:
subject: implicit jsp objects
It's not a secret anymore!