How can I share objects across different sessions?
Answers were Sorted based on User's Feedback
Answer / sanjeev kumar
Information (It can be primitives or objects) can be shared
across different servlets in 3 ways in J2EE.
1) Request object-- If the data need to be shared with in
the request scope we can set it on request object with
request.setAttribute() method. And can be accessed from the
other servlet or JSP with request.getAttribute() method.
2) Session object-- If the data need to be shared with in
the session scope we can set it on session object with
session.setAttribute() method. And can be accessed from the
other servlet or JSP with session.getAttribute() method.
3) Context object-- If the data need to be shared with in
the context (Application) scope we can set it on context
object with context.setAttribute() method. And can be
accessed from the other servlet or JSP with
context.getAttribute() method.
| Is This Answer Correct ? | 16 Yes | 4 No |
with the help of session.setAttribute()and session.getAtribute()we can share Httpsession object across different servlet and jsp.
| Is This Answer Correct ? | 5 Yes | 0 No |
how do you maintain sessions in servlets?
What are the difference between session and cookies in servlet? Explain
Can we override the ActionServlet?
3 Answers ArisGlobal, HCL, PPF,
What is servlet initializer?
Life Cycle of servlets?
How many ways to remove the session object in the container
How to make sure a servlet is loaded at the application startup?
if we know the any consultancies, it will place in company work through consultancy(contract base). please help me I'm 2008 pass out java candidate...
What is the servlet?
Write a program to show the functionality of doget and dopost method?
What is the use of servlet wrapper classes?
What is the difference between JspWriter and PrintWriter