tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Heinemann <heine...@horacemann.com>
Subject JSP file not finding object
Date Fri, 02 Jun 2000 18:10:37 GMT
Hi everybody,

I have a slight problem.  With a servlet I create a Vector filled with
Strings (error messages).  I add that to the session.  After that I
redirect to a JSP.  The JSP can't get the value back out of the
session.  Here is the relivant code:
<SERVLET>
try{
         System.out.println  ((String)req.getParameter ("ANSWER"));

     p.setAnswer ( (String)req.getParameter ("ANSWER"));
 }catch (Exception e){
     ok=false;
     errors.add (e.getMessage ());
 }
 try{
         System.out.println  ((String)req.getParameter ("PASS1"));
     System.out.println  ((String)req.getParameter ("PASS2"));

     String pass1 = (String)req.getParameter ("PASS1");
     String pass2 = (String)req.getParameter ("PASS2");
     if (pass1.equals (pass2)){
  p.setPassword ( (String)req.getParameter ("SSN"));
     }else{
  p.setPassword (null);
     }
 }catch (Exception e){
     ok=false;
     errors.add (e.getMessage ());
 }

 for (int i=0;i<errors.size();i++){
     System.out.println ((String)errors.elementAt (i));
 }

 session.setAttribute ("errors",errors);
  </SERVLET>

<JSP>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
 <title>Please complete the form to create your account.</TITLE>
</head>
<body bgcolor=#FFFFFF >

<TABLE width="100%" cellpadding=2 cellspacing=0 valign="top"
align="middle" >

<TR>
 <td><BR>
 <% Vector errors = (Vector) session.getAttribute ("errors");
  if (errors != null){
   //session.removeValue("errors");
   if (errors.size() > 0){
    %><UL>
    <% for (int i=0;i<errors.size();i++){
     %><LI><%=(String)errors.elementAt(i) %>
    <% } %></UL><%
   }else{%>blah<%}
  }else{
 %><%=(String)session.getAttribute ("TIME")%><% }
 %><BR>
 Please complete all fields.<BR>
 <form action="/servlet/com.hm.servlets.Login" method="Get" >
  <input type="hidden" name="ACTION" value="REGISTER" >
  Your social security number : <input type="text" name="SSN" ><BR>
  The password you would like : <input type="password" name="PASS1"
><BR>
  Your password again : <input type="password" name="PASS2" ><BR>
  Your email address : <input type="text" name="EMAIL" ><BR>
  Your hint question: <input type="text" name="HINT" ><BR>
  Your hint answer : <input type="text" name="ANSWER" ><BR>
  Your account number : <input type="text" name="CONTRACTNUM" ><BR>

  <input type="submit" name="Submit Request for an Account"
>&nbsp;&nbsp;<input type="reset" ><BR>
 </form>
 </TR>
</TABLE>

</BODY>
</HTML>
</JSP>

Any help is appreciated....

Thanks,
Chris Heinemann


Mime
View raw message