On Fri, 29 Nov 2002, Aasim wrote:

>
> Becky,
> Thanks for your reply. My browser didn't accept cookies. I enabled them.
> Please correct me if I am wrong! I was under the impression that
> Session Management using Servlets API does not require the use of
> cookies. I thought Session Tracking using URL Rewriting, Using
> Cookies and Using Hidden Form Fields were old methods of session
> tracking and servlet API was designed so that one can do session
> management without having to use any of these. Is that true?
>
> If yes, why would I require to enable cookies in order to run my code?
> Thanks for the help!

You are correct that using sessions does not require using cookies.
You can also use URL Rewriting.  But that does not happen
automatically, you must set it up.  Like using encodeURL() and such.
There is no built-in way to use hidden form fields; I suppose you
could set that up yourself, but it would require more work, and there
might be secuity implications.

I have never used anything other than cookies for sessions,
fortunately I've worked in an environment where I knew cookies would
be enabled.  So I don't know how problematic using URL Rewriting is.
But I'm glad I don't have to use it :-); certainly using cookies is
the simplest.


>  Becky Phaneuf <[EMAIL PROTECTED]> wrote:Andy,
>
> Does your browser accept cookies? If not, turn on the acceptance of
> cookies b/c the session object makes use of them to "remember"
> itself.
>
> You have to first retrieve the session, then retrieve the object
> from it. Did you do that?
>
> I would assume this is your code:
>
> setting: HttpSession sessionName = requst.getSession();
> sessionName.setAttribute("objectName", someObject);
>
> getting: HttpSession sessionName = request.getSession();
> someObject objectName = (someObject) sessionName.getAttribute("objectName");
>
> If not, fix your code.
>
> It's possible to maintain a session w/out cookies, but you'll have to look that up 
>yourself. :)
>
> -B
>
> >>> [EMAIL PROTECTED] 11/29/02 07:32AM >>>
>
> Frans,
> Thanks for your reply.
> It is in the same servlet context. Are you saying that it is in the same directory? 
>All my files are in the same directory. However, I do have my classes and the web.xml 
>file stored in the WEB-INF directory within my main application directory.
> Any suggestions or ideas that I could possibly try?
> Thanks!
> --Andy.
>
> Frans Verhoef wrote:Andy,
> Is the page to which you are redirecting a servlet inside the same ServletContext. A
> session can only be used from within the same ServletContext, i.e. the web 
>application
> directory.
>
> Frans
>
> On 27 Nov 2002 at 22:19, Aasim wrote:
>
> >
> > Dear Servlet-interest users:
> > I am new to servlets and I need your help.I am having a problem with session 
>management. I add
> > an object to a new HTTP session ina servlet class. Then I redirect my servlet to 
>another page. I
> > need to access the originalobject that I previously addedon this page, which is a 
>new class.
> > When I try to retrieve the original object from another class using 
>getAttribute(), it gives me anull
> > value. Can this be done? Am I doing something wrong over here or am I missing 
>something?
> > Thanks for the help in advance.
> > Sincerely,
> > --Andy.

Milt Epstein
Research Programmer
Integration and Software Engineering (ISE)
Campus Information Technologies and Educational Services (CITES)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]

___________________________________________________________________________
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

Reply via email to