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 servlet context ?

4 Answers  


What is the default http method in the servlet?

0 Answers  


How do you configure a centralized error handler in servlets?

0 Answers  


Which are the different ways you can communicate between servlets?

0 Answers  


What are cookies and how will you use them?

2 Answers  






Directive Include and Action Include how both are working in JSP, what is the difference between both?In which suituation we have to choose these elements?

4 Answers   AZTEC,


What is HTTP Tunneling?

1 Answers   Wipro,


How do cookies work in servlets?

0 Answers  


What is the advantage of Servlets when compared with other server side technologies?

0 Answers  


Is there any differance b/w getting servlet context from servlet config and session? if yes then what is that?

7 Answers  


How can the session in servlet be destroyed?

0 Answers  


what are the different services provided by the web server?

2 Answers  


Categories