The session object works similiar to a hashtable. It can contain any Java
object, although that is necessarily recommended. Remember not to forget to
cast from Object on retrievals.

// put it in the session

String thisString = rs.getString("FIRST_NAME");
HttpSession session = request.getSession(true); // create if null
session.setAttribute("FIRST_NAME", thisString);

//----------------------------------------------


// retrieve and remove from the session at a later stage

HttpSession session = request.getSession(); // don't create if null
String thatString = null;
if (session != null)
        thatString = (String)session.getAttribute("FIRST_NAME"); // cast to
String
        session.removeAttribute("FIRST_NAME");
else...

//----------------------------------------------



-----Original Message-----
From: Kate McNamara [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 08, 2000 12:04 PM
To: [EMAIL PROTECTED]
Subject: FW: JSP & Sessions & Recordsets


Hi Folks,

I have an exceedingly elementary question about JSP.  I am trying to process
a login for a user, validating the data from the database and then setting
up
session variables.

I am a native ASP programmer, but thought I was making progress in JSP,
though
it seems not.  My greatest hurdle at the moment is making a field from a
recordset
equal to a local variable (string).  I can't seem to do it.

        In ASP I would do something along the lines of: (post
declaration)...

                thisString = rs("FIRST_NAME")

        I understand the JSP equivalent to be:

                String thisString = rs.getString("FIRST_NAME");

Then...my problems continue.  I am not sure how to declare, write to or
retrieve
session variables.  Any assistance would be great appreciated.

Cheers,

Kate McNamara
www.atomicdesign.com.au

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to