How can I share objects across different sessions?

Answers were Sorted based on User's Feedback



How can I share objects across different sessions?..

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

How can I share objects across different sessions?..

Answer / aman kumar

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

Post New Answer

More Servlets Interview Questions

What is the difference between sendredirect() and forward() in a servlet?

0 Answers  


What are the differences between the servletconfig interface and the servletcontext interface?

0 Answers  


Explain the servlet context.

0 Answers  


What is the difference between the http servlet and generic servlet?

0 Answers  


What are the different types of servlets?

0 Answers  






can it possible to validate form field before execution of a servlet service method if yes how??

6 Answers  


How can the session in servlet can be destroyed?

0 Answers  


what is servlet and what you get when we use servlets?

7 Answers   GGK Tech, Satyam,


What's the servlet interface?

0 Answers  


can i call init() method in destroy() method of servlset. ?

5 Answers   IBM,


How does tomcat servlet container work?

0 Answers  


What's the difference between authentication and authorization?

0 Answers  


Categories