Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: help on some of this jsp pages


Message #1 by Super Powerfulrez <powerfulrez@g...> on Mon, 19 Mar 2001 09:36:47 -0800 (PST)
Hi,

I believe (not tested in real practice) you always receive the error page 
template.jsp is because of this line of code :

if ( ( mid == md ) && ( passw == pass ) )

mid, md, passw and pass are defined as String objects. You are comparing 
String objects, not the value it contains, that's why it never work. Use 
the following function instead and try again ...

if ((mid.equals(md) && (passw.equals(pass))

Hope it helps....


> 
> this is loginnow.jsp:
> <%@ page language="java" import="java.sql.*" %>
> <% 
>   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
>   Connection myConn = DriverManager.getConnection("jdbc:odbc:library");
> 
>   String mid = request.getParameter("memberid");
>   String pass = request.getParameter("pw");
> 
>   Statement stmt = myConn.createStatement();
>   ResultSet myResultSet = stmt.executeQuery("select * from member");
> 
> 	if (myResultSet !=null)
> 	{
> 	while (myResultSet.next())
> 		 {
> 		  String md= myResultSet.getString("member_id");
> 		  String passw = myResultSet.getString("password");
> 		
> 			if ( ( mid == md ) && ( passw == pass ) )
> 			{
> 				session.putValue("member_id", mid);
> 				%>
> 				<jsp:forward page="testing.jsp"/>
> 				<%
> 			}
> 		  }
> 	}
> 	%>
> 		<jsp:forward page="templete.jsp"/>
> 	<%
>   stmt.close();
>   myConn.close();
> %>
> 
> 
> this is 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>
> 
> please help me out
> kinda in a hurry
> 
> benjamin
> 
> ___________________________________________________
> GO.com Mail                                    
> Get Your Free, Private E-mail at http://mail.go.com
> 
> 

  Return to Index