• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

implicit jsp objects

 
Gowher Naik
Ranch Hand
Posts: 643
  • 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
jQuery Spring Java
  • 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
  • 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
  • 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
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well said abhijeet ! and i like your signature ...

Stay connected, be beautiful
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!