How can I share objects across different sessions?
Answers were Sorted based on User's Feedback
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 |
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 |
My Question is that i am using <image> tag in my servlet and after compilation after that calling by url in my browser then images are not showing. Sometime images are showing and sometime is not showing. I am using Tomcat to run my servlets. Tell me if there any specification for image in servlets or what is solution for this ??
What happens, if server sends a cookie to a browser that doesn't supports cookies?
Write a command to get actual path of a servlet to the server?
List out the difference between ServletConfig and ServletContext?
What is context switching?
difference between forward and sendredirect
What is cgi and what are its drawbacks?
What is the process to implement doget and dopost methods?
what is servlet life cycle?
What is the GenericServlet class?
Which method of the httpservletrequest object is used?
What is getservletcontext?