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
When should you prefer to use doget() over dopost()?
What is the purpose of inter-servlet communication?
What is the web server used for running the Servlets?
Explain session tracking and its importance?
what is multiple server?
What do you mean by annotations in servlet?
What is servlet collaboration?
What are some advantages of storing session state in cookies?
How to commuincate between an applet and a servlet?
What is servlet in tomcat?
request parameter how to find whether a parameter exists in the request object?
hi actully i hav form columns with origin and destination names .as like as i need to create one more column with name amount. my requirement is when i select origin and destination columns automatically i need to get amount from database.how can i. please tel me with relative code
What do you mean by cgi in servlet?
Elucidate servlet attributes and its scope?
In the servlets, we are having a web page that is invoking servlets ,username and password? which is checks in database? Suppose the second page also if we want to verify