How can I share objects across different sessions?
Answer Posted / 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 |
Post New Answer View All Answers
Explain their methods? Tell me their parameter names also have you used threads in servlet?
what is servlet chaining?
What are the types of protocols supported by httpservlet ?
When servlet object is created?
How forward () method is different from send redirect () method?
How to read request headers from servlets?
Explain the servlet context.
What is the major difference between servlet and applet?
What is servlet and its use?
Write all the phases defined in servlet life cycle?
What is the inter-servlet communication?
What is the workflow of a servlet?
What are important features of Servlet 3?
why we should override only no-agrs init() method.
How to get the server information in a servlet?