Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to pass session values from one servlet container to another servlet container? or how can we get session values of one container in another container?

Answer Posted / satishkumar vishwakarma

We can Pass Session value from servlet container to another
with the help of Session Object
E.g. I have two Servlet named ServletA and ServletB if i
want to pass value from ServletA to ServletB using Session
Object.
i.e. HttpSession session = request.getSession();
//Now i want to pass my name from ServletA to ServletB
String s = "Satishkumar V";
session.setAttribute("myname",s);
//Now i want to display this name in ServletB Then we will
write the following code in ServletB

HttpSession session = request.getSession();
String s = (String)session.getAttribute("myname");

//Now we can display the value of s in anywhere in Servlet B
out.println("<h1>"+s+"</h1>");

Is This Answer Correct ?    10 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between the getrequestdispatcher(string path) method of javax.servlet.servletrequest interface and javax.servlet.servletcontext interface?

1027


What are the kinds of http requests?

1032


What do you mean by scope object and what are its types?

1065


Can a jsp be called using a servlet?

1126


List the Different types of servlet?

1034


Explains the differences between context.getrequestdispatcher() and request.getrequestdispatcher()?

1016


Is java servlet still used?

1038


What is the main purpose of java servlets?

1048


What is new in ServletRequest interface ? (Servlet 2.4)

1006


How httpservlet is different from the genericservlet?

1117


What is meant by session? Tell me something about httpsession class?

1008


Explain servlet life cycle?

1122


How can we create deadlock situation in servlet?

1428


What are the difference between session and cookies in servlet? Explain

1038


Can you send an authentication error from a servlet?

965