Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

servelet to JSP communication..

Status
Not open for further replies.

patnim17

Programmer
Jun 19, 2005
111
US
Hi,
I have a Servelet that invokes a java object that makes connection to the database and executes the SQL and returns an object that contain an xml list of data from the database. Once I get this object back in the servlet, I need to send the control to a JSP page with this java object..

how can I acomplish this..please help.

nims
 
Hi,

You can set the Java Object as request attribute in the servlet and dispatch the request object to JSP page.

ex: In servlet

Code:
RequestDispatcher dispatcher = 
getServletContext().getRequestDispatcher("test.jsp");
// object that has been built from DB
request.setAttribute("xmlObject", object);
dispatcher.forward(request, response);

in test.jsp you can acess the object

Code:
 Object obj = (Object)request.getAttribute("xmlObject");

Cheers
Venu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top