dcsimg
How do you pass Http Request and Session Info from a JSP page into a Java class
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Marty_Smith
Posted On:   Tuesday, October 3, 2006 01:43 PM


I need to call this class from a jsp page and need an example of how I can create a reference to the objects in the jsp page so I can pass them to the class below

			
public String getRequesterID(
ServletContext servlet,
HttpSession session,
HttpServletRequest request)

Re: How do you pass Http Request and Session Info from a JSP page into a Java class

Posted By:   Byron_Tymvios  
Posted On:   Wednesday, October 4, 2006 10:38 AM


JSP has a few implicit objects which are available to the developer "by default", that is you don't need to create/instantiate any objects. So the references to these objects are already there you just need to know the names.



The HttpSession object is called session, the HttpServletRequest object is called request. There is no reference to a ServletContext object BUT there is a reference to a PageContext object which has a reference to a ServletContext, you use pageContext.getServletContext() to get a reference to it.



//In your JSP
getRequesterID(pageContext.getServletContext(), session, request);

That should do it.


For a list of all the implicit objects available go HERE

About | Sitemap | Contact