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

Why do we have servlet listeners?

0 Answers  


if we know the any consultancies, it will place in company work through consultancy(contract base). please help me I'm 2008 pass out java candidate...

1 Answers  


What is ServletConfig object?

0 Answers  


What is the ServletConfig() and what is its use?

4 Answers   Google,


What is the workflow of a servlet?

0 Answers  






How to work with Chinese login page (internationalization).if he enters user name and password in chinese, how is it converted to English and validate in db? And in reverse it should display welcome message in Chinese,if user is valid

4 Answers   Bosch,


What are the life cycle methods of the servlet?

0 Answers  


What are the types of an http request?

0 Answers  


What is servlet name in web xml?

0 Answers  


What are the phases of the servlet life cycle?

0 Answers  


What is HTTP Tunneling?

1 Answers   Wipro,


What is servlet looping or chaining?

0 Answers  


Categories