This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Servlets and JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlets and JSP" Watch "Servlets and JSP" New topic
Author

Servlets and JSP

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
hi
how to pass objects from one servlet to another servlet.
please give me small example.
Thankyou
regards
Ramya
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
One of the easiest ways to pass an object around between servlets and Javaserver Pages is with a Session (javax.servlet.http.HttpSession)
Sessions are objects that are managed by the servlet engine and are identified by a unique "cookie" value. You can attach an arbitrary object to a session in one servlet with:
session.setAttribute("objname", theObj);
and get it back with
notherObj = (objtype)session.getAttribute("objname");
Use the HttpRequest method getSession() to get the
session associated with a request.
NOTE: the user's browser must be set to accept cookies.

------------------
 
Don't get me started about those stupid light bulbs.
 
subject: Servlets and JSP
 
Similar Threads
Capturing Form Data
javascript, servlets and SVG
Export in Excel
How can I change the sdk version of Websphere 4 if I already install it
Is there any way to get Servlet Init Parameter using EL?