>
> What is the correct way to call classes from a servlet?
> Currently, I am just
> creating an object of a class and passing arguments to it. I
> have recently seen
> code out there that puts objects into session objects. What are
> the advantages
> to this and is this more appropriate than the latter?
>
Hi,
The issue is to do with state and whether you need to keep objects bound
to a session.
All web requests are stateless, ie they have no way of directly knowing
what has happened before. One way of recording state information
which is preserved across requests is to use an HttpSession object
to store things in.
If you are creating objects that are only local to the request method being
called then you have no need to store state information (ie the objects).
If however you need to store objects for a session then store the object(s)
in the HttpSession object using the putValue(String key, Object value)
method
and retrieve it/them using the getValue(String key) method.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html