Hi

Is there in the same file the scriptlet and de html code?, if so, the
problem is that the first time the page is requested, both username and
password don't exist, so when you try gettinf their values, you get null
and else statement is executed.


I hope this was useful.

Dani

----- Mensaje Original -----
De: Chin Sung Kit <[EMAIL PROTECTED]>
Fecha: Jueves, Septiembre 28, 2000 8:46 am
Asunto: jsp login page

> hi,
>
> can anyone point out what is wrong with my code?  when i first
> load the
> page, the message, "please fill in the form again, blah blah" already
> appeared.  i thought i put an ELSE statement there.
>
> can anyone shed some light on this?
>
> ced
>
> below is the jsp code:
>
> <%@page language="java" import="java.sql.*, jsp.*, javax.servlet.*"%>
> <jsp:useBean id="beanConnect" class="jsp.DbBean" scope="application"/>
> <%@page session="false"%>
> <%
> String userId = request.getParameter("username");
> String password = request.getParameter("password");
> if ((userId != null) && (password != null)) {
> String sql = "select userid from t_staff where userid='" + userId +
> "'and password='" + password +"'";
> beanConnect.connect();
> ResultSet rs = beanConnect.execSQL(sql);
>
> if (rs.next()) {
>  HttpSession userSession = request.getSession(true);
>  userSession.putValue("userName", userId);
>         response.sendRedirect("/test/jsp/home.jsp");
>        }
> }
> else {
> out.println("<h3>Please fill in the form again!  You have typed in
> either the wrong USERID or PASSWORD</h3>");
> }
> %>
> <html>
> <head>
> <title>eDORIS Login</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-
> 8859-1">
>
> </head>
> <body bgcolor="#FFFFFF">
> <form name="loginform" method="post" action="/test/jsp/Login.jsp">
>  <p>User Name:
>    <input type="text" name="username">
>  </p>
>  <p>Password:
>    <input type="password" name="password">
>  </p>
>  <p>
>    <input type="submit" name="Submit" value="Sign In">
>  </p>
> </form>
> </body>
> </html>
>
>
========================================================================
===
> 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