Hi,
I tried whatever you said. I created a bean with getter,setter methods on
userName,password. And in the verification.jsp, I used useBean tag with
scope="session". How do i use this in another jsp page? again i have use
useBean tag with session scope or is there any other way. Some times i'm
getting ClassCastException.
Here are small code samples on each page:
/************* start *********************************/
which i'm using in verification.jsp:
<jsp:useBean id="userInfo" class="com.nalini.servlets.UserInfo"
scope="session" >
<jsp:setProperty name="userInfo" property="*" />
</jsp:useBean>
<% String user = userInfo.getUserName();
String password = userInfo.getPassword();
//do all data base checking. If correct information provided by
//the client then forward to generate.jsp otherwise go to error.jsp
%>
------------------------------------------------------------------------
Here is the code in generate.jsp:
<jsp:useBean id="userInfo" class="com.nalini.servlets.UserInfo"
scope="session" >
<jsp:setProperty name="userInfo" property="*" />
</jsp:useBean>
<% System.out.println(userInfo.getUserName()); %>
<%-- rest is HTML page --%>
<form name="myForm1"
action="../servlet/com.nalini.security.GenerateKeysServlet" method="GET">
Enter a name to Key Pair<input type="text" name="nameToPair" size="20">
Enter Public Key name:<input type="text" name="publicKeyName" size="20">
Enter Private Key name:<input type="text" name="privateKeyName" size="20">
<input type="submit" value="Generate Keys" name="genKeys">
</form>
---------------------------------------------------------------------
In the GenerateKeysServlet's doGet, I'm writing the following code:
String userName = request.getParameter("userName");
GenerateSecurity genSec = new GenerateSecurity(); //this is not a bean.
genSec.generatePublicAndPrivateKeys(userName,publicKeyName,privateKeyName);
/******************** end **********************************/
Hope you got my problem.
Janavee.
>From: Ravi Prashanth <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
> reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: Problem wih servlets and JSP
>Date: Wed, 7 Feb 2001 16:06:55 -0800
>
>There are many ways to do this :
>
>1st Method
>----------------
>If the username/password combination has been verified to be ok by
>verification.jsp, then before sending it to main.jsp, you can add the
>username to the session (HttpSession) and retrieve it from main.jsp using :
>
>String username = String.valueOf(session.getValue("username.session"));
>
>Once you've retrieved the username in your jsp as a string, then either use
>a setUsername() setter method to pass the value to your bean (which is
>nothing but a method, as you want) or directly call the method using the
>bean [UrbeanName.yourmethod(username)]
>
>2nd Method
>-----------------
>You can pass it as a hidden form field from verification.jsp to main.jsp
>
>
>Feel free to email me if you need some help.
>
>- Ravi
>http://Babynamesindia.com
>------------------------------------------
>Download our Free Screensaver
>With pictures of the World's Cutest Babies
>Only at : http://Babynamesindia.com
>------------------------------------------
>
>
>
>At 03:39 PM 2/7/01 -0500, you wrote:
>>Hi all,
>>
>>Step1: I have a login.html page which sends info'(userName and password)
>>to
>>verification.jsp page. Here the info' is verified and if the info is
>>correct
>>then it goes to main.jsp.
>>
>>Step2: In this main.jsp page i want to access the userName and send it to
>>the servlet which calls the method of class XXX by passing this userName.
>>
>>I'm able to do till Step1. In Step2, i'm accessing userName through
>>request.getParameter("userName") and i have to pass it to the servlet.
>>Here
>>i'm so confused, how i can i pass the userName to
>>methodX(userName) of class XXX, which does some database operation based
>>on
>>the userName.
>>
>>What i've done is accessing userName through HttpServletRequest object in
>>the servlet class and calling the methodX(userName) of XXX. But userName
>>was
>>not sent. null went into the method. I'm so confused.
>>
>>I appreciate your help.
>>
>>Thanks,
>>Janavee.
>>_________________________________________________________________
>>Get your FREE download of MSN Explorer at http://explorer.msn.com
>>
>>===========================================================================
>>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>>JSP-INTEREST".
>>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
>>DIGEST".
>>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".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
>DIGEST".
>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
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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