Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pageContext Implicit object

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

What it means by saying "The pageContext object knows about all the other implicit objects, and it has methods to get hold of them."

Can anyone provide some examples!!
 
Mahesh Desai
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jothi,

PageContext API provides access to the JSP implicit objects. It has exposed following methods to access these implicit objects:

getException()
getPage()
getOut()
getRequest()
getResponse()
getSession()
getServletConfig()
getServletContext()


You could see the Servlet code which is translated from JSP file, you will see something like this:


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

...other code
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;

...other code

//get it from somewhere
pageContext = JspFactory.getDefaultFactory().getPageContext
(this, httpservletrequest,
httpservletresponse, "XXXXX.jsp", true, 8192, true);

session = pageContext.getSession();
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
out = pageContext.getOut();

...other code
}


Thanks,
Mahesh

---------
SCJP 1.4 | SCWCD 1.4 | SCBCD 1.3 | SCEA Part I - In Progress
[ April 13, 2007: Message edited by: Mahesh Desai ]
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mahesh,

Thanks for the help offered!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic