here are some observations..

it looks as though you are trying to get your values from the session when
you should be getting them from the form.  in your doPost method you should
use request.getParameter(String paramName) to get the form element values.

you also do not have an ACTION attribute in your form tag.  shouldn't you
include that to tell your page where to send the form?

bradley mclain

>From: Tara Marjoram <[EMAIL PROTECTED]>
>Reply-To: "A mailing list for discussion about Sun Microsystem's Java
>        Servlet API Technology." <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Getting values from Html objects
>Date: Fri, 17 Mar 2000 09:02:37 +0000
>
>Hi all,
>
>A really easy question for you? I can't seem to get values out of a html
>form using my servlet.  This is for example Name and password values.
>The following code:
>
>In the doGet method:
>out.print("<HTML><HEAD><TITLE>Login</TITLE>");
>                                 out.print("</HEAD><BODY><FORM
>METHOD=\"POST\">");
>                                  out.print("<INPUT TYPE=\"TEXT\"
>NAME=\"login\">");
>                                  out.print("<INPUT TYPE=\"PASSWORD\"
>name=\"password\">");
>                                  out.print("<INPUT TYPE=\"SUBMIT\"
>name=\"submit\">");
>                                  out.print("</FORM></BODY></HTML>");
>                                  out.close();
>
>In the doPost method:
>
>   String msg;
>                                 HttpSession session =
>req.getSession(true);
>                                 if (req.getParameter("submit") != null)
>                                         {
>
>msg=(String)session.getValue("login.text");
>
>msg+=(String)session.getValue("password.text");
>                                         System.out.println("The msg val
>is " + msg);
>                                         res.setContentType("text/html");
>
>                                         res.setHeader("pragma",
>"no-cache");
>                                         PrintWriter out =
>res.getWriter();
>
>out.print("<HTML><HEAD><TITLE>Values</TITLE></HEAD><BODY>");
>                                 out.print(msg);
>
>
>****I get null values written to the html page on doPost().
>
>Please can anyone tell me why and how to correct this.  Even if I write
>the doGet() code as hard coded html, it doesnt work.
>Basically all I want to do is print the name/password values entered
>from the user on the html page.
>
>Thnx
>
>___________________________________________________________________________
>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

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

___________________________________________________________________________
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