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 |
Why HttpServlet class is declared abstract?
Explain the concept of ssi ?
What is the servlet?
What is the use of welcome-file-list?
What is the difference between doGet and doPost?
How to make servlet thread safe?
9 Answers Frisco Tech, InfoVista, WipSys Technologies,
What do you mean by httpservlet?
Can we use servlets in JavaScript?
Can you refresh servlet in client and server-side automatically?
What are the important functions of filters?
How servlets can be automatically reloaded?
What are cookies and how will you use them?