|
 |
pro_jsp thread: really really need help on this.... very urgent
Message #1 by Super Powerfulrez <powerfulrez@g...> on Sun, 25 Mar 2001 06:46:22 -0800 (PST)
|
|
Hi,
I answer your previous question, I suppose you haven't read it yet, should
try pass.equals(password) instead of pass==password. String works
differently compare to other variables (integer, double) in Java.
If you're using session and response.redirect() in servlet, remember to
encode your link before redirect().
Use session.setAttribute() and session.getAttribute() instead of
session.putValue. putValue() has been deprecated since servlet 2.2, but
it's ok if you insist or you're using a older version of Java web server
which only supports servlet 2.1 .
Here is a suggestion, if you want to debug the code, try to print them,
out.println(pass) to see the result. Remember to remark (disable) your
response.redirect().
Hope it helps...
> this is on the login procedure again
> here are the codes please check it and see where have i gone wrong
> if possible please help me to edit it also and also teach me how to use
the properties of the session in my other jsp pages
>
> index.htm:
>
> <html>
> <head>
> <title>Untitled Document</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> </head>
>
> <body bgcolor="#FFFFFF">
> <form method="post" action="loginnow.jsp">
> <p>Member ID
> <input type="text" name="memberid" maxlength="15" size="15">
> Password
> <input type="password" name="pw" size="15" maxlength="15">
> </p>
> <p>
> <input type="submit" name="Submit" value="Login">
> </p>
> </form>
> </body>
> </html>
>
>
> loginnow.jsp
> <%@ page language="java" import="java.sql.*" %>
> <%
> String mid = request.getParameter("memberid");
> String pass = request.getParameter("pw");
> String jsp;
>
> if (mid==null)
> {
> jsp = "/index.htm";
> }
> else
> {
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> Connection myConn = DriverManager.getConnection
("jdbc:odbc:library");
> Statement stmt = myConn.createStatement();
> ResultSet myResultSet = stmt.executeQuery("select * from member
where member_id = mid");
> String password = myResultSet.getString("password");
>
> if (myResultSet !=null)
> {
> while (myResultSet.next())
> {
> if (pass == password){
> session.putValue("member_id", mid);
> jsp = "templete.jsp";
> }
> }
> stmt.close();
> myConn.close();
> return;
> }
> else
> {
> jsp="/index.htm";
> }
>
> }
> response.sendRedirect(jsp);%>
>
> ___________________________________________________
> GO.com Mail
> Get Your Free, Private E-mail at http://mail.go.com
>
>
|
|
 |