Here it is!
Assume that you got a JSP file that has 2 edit controls. You type some text
into those controls and when you click the submit button you want them to be
displayed on the next page, along with a session object that's stored
<%
String myString = new String("I'm a session variable");
session.putValue("SESSIONVARIABLE",myString);
%>
..............
.............
<FORM METHOD="POST" ACTION="nextPage.jsp"> <!-- This tag is important -->
..............
<INPUT TYPE="TEXT" NAME="USERNAME" VALUE="">
<INPUT TYPE="PASSWORD" NAME="PASSWORD" VALUE="">
............
............
<INPUT TYPE="SUBMIT" VALUE="Click Me!">
</FORM>
When you click on the "Click Me!" button you are redirected to the next JSP
page and you can get the user name and password form variables by using the
getParameter() function and the SESSIONVARIABLE by using the getValue()
function.
<%
...............
..............
if(session == null){
try{
.................
response.sendRedirect("firstPage.jsp");
}
catch(Exception exp){
................
}
finally{
..............
return;
}
}
String userName = request.getParameter("USERNAME");
String password = request.getParameter("PASSWORD");
/* Always Type Cast Your Return Value From The Session Object */
String sessionString = (String)session.getValue("SESSIONVARIABLE");
%>
.............
That's it!...you have access to all the three variables from the previous
form. However you need to check for the validation/existence of the session.
Also make a note that the session, request objects are inherently available
to a JSP file, so you can use them directly as I've done!!
Hope this is of some help
Cheers
Ramesh
RAMESH NORI
INFOGAIN
485 ALBERTO WAY
LOS GATOS, CA 95035
+1-408-355-6000 (SWITCH)
+1-408-355-6024 (DIRECT)
+1-408-730-4044 (HOME)
+1-408-738-4634 (HOME)
[EMAIL PROTECTED] (off)
[EMAIL PROTECTED] (public)
http://members.tripod.com/RAMESH_NORI/myself.htm
----- Original Message -----
From: Kallur, Padmaja (GEL, MSX) <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, September 24, 1999 7:55 AM
Subject: read and write cookies
> Hi all,
>
> Can anyone tell me how to read and write cookies.
>
> Any code sample will be highly appreciated.
>
> Thank you guys.
> Padmaja
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html