Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

implicit jsp objects

 
Gowher Naik
Ranch Hand
Posts: 643
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 502
Java jQuery Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Elan Ram
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey we can access implicit object inside jspInit()/jspDestroy() method.

Eg
config implicit object.
 
Rohitt Vermaa
Ranch Hand
Posts: 232
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The implicit objects are the local variables inside the _jspService method. So jspInit() and jspDestroy() have no access to it.
 
Abhijeet Mahule
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1277
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well said abhijeet ! and i like your signature ...

Stay connected, be beautiful
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic