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

0 Answers  


What do you mean by cgi?

0 Answers  


What are setSecure() and getSecure() methods in Cookies?

1 Answers  


How do we go with database connection and log4j integration in servlet?

0 Answers  


What are the kinds of http requests?

0 Answers  






What is lazy loading and what is Generic Servlet Class?

0 Answers  


Define the lifecycle for executing a jsp page.

0 Answers  


i have class files in class folder. but i have no java files. but i want to modify the java files which are related to class files . how ?

5 Answers   TCS,


Is it possible to send a mail from a servlet? Explain?

4 Answers  


What is the disadvantage of cookies?

0 Answers  


What is the need of session tracking in web application?

0 Answers  


Which http method is said to be non-idempotent and idempotent?

0 Answers  


Categories