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 do you mean by chaining in servlet?

568


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

596


What are the important functions of filters?

594


What is the servlet?

618


What is servletconfig?

543






What do you mean by url pattern in servlet?

621


Tell the new features added in servletrequest interface i.e. Servlet 2.4

573


What is the use of welcome-file-list?

570


How can I send user authentication information while making URL Connection?

541


What is servlet and its use?

623


Can a jsp be called using a servlet?

580


What is the inter-servlet communication?

698


Describe in brief RequestDespatcher?

593


What are the difference between RMI and Servlets?

1049


What are the different methods of session management in servlets?

532