aspose file tools*
The moose likes Servlets and the fly likes what's wrong Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "what Watch "what New topic
Author

what's wrong

Kavita Ghia
Ranch Hand

Joined: Oct 10, 2000
Posts: 91
The following is java bean
import java.sql.*;
public class UserInfoBean {
private String username;
private String password;
private boolean validUsername;
private boolean validPassword;
private String driver="sun.jdbc.odbc.JdbcOdbcDriver";
private String protocol="jdbc dbc:db";

public UserInfoBean() {
try {
Class.forName(driver);
} catch(ClassNotFoundException e) {}
}
public void setUsername(String username) {
this.username = username;
}
public void setPassword(String email) {
this.password = password;
}
public String getUsername() {
return username;
}
public String getPassword() {
return password;
}
public boolean isValidUsername() {
return validUsername;
}
public boolean isValidPassword() {
return validPassword;
}
public void registerSupportRequest() throws SQLException
{
Connection connection = null;
String selectUsername = "SELECT MEMBER.USERNAME FROM MEMBER WHERE MEMBER.USERNAME = ?";
try
{
connection = DriverManager.getConnection(protocol);
//verify Username
PreparedStatement pstmt1 =connection.prepareStatement(selectUsername);
pstmt1.setString(1,username);
ResultSet rs1 = pstmt1.executeQuery();
if (rs1.next())
{
validUsername= true;
String user=getUsername();
String password=getPassword();
String selectPassword ="SELECT PASSWORD FROM MEMBER WHERE USERNAME='"+(user)+"' and password='"+(password)+"'";
//verify password
Statement stmt = connection.createStatement();
ResultSet rst2=stmt.executeQuery(selectPassword);
if(rst2.next())
validPassword=true;
else
validPassword=false;
}

else {
validUsername= false;
}
}
finally {
if (connection != null) {
try {
connection.close();
} catch (SQLException sqle) {}
}
}
}
}
Now this the process.jsp file that i call whenever the user logins.
Process.jsp
==============
<%@ page language="java"%>
<%@ page errorPage="error.jsp"%>
<jsp:useBean id="userInfo" scope="session" class="UserInfoBean"/>
<jsp:setProperty name="userInfo" property="*"/>
<% userInfo.registerSupportRequest() ; %>
<% if (userInfo.isValidUsername())
{
if (userInfo.isValidPassword())
{ %>
<jsp:forward page="valid.jsp"/>
<% }
else {%>
<jsp:forward page="invalid1.jsp"/>
<%}
}
else { %>
<jsp:forward page="invalid.jsp"/>
<% } %>
In the above code why do i always get an invalid password even though i enter the correct password.
Amber Woods
Ranch Hand

Joined: Mar 28, 2001
Posts: 111
I'm a newbie to servlets and the like but I did notice your line of code here
public void setPassword(String email) {
this.password = password;
}
My guess is that it should probably be:
public void setPassword(String email) {
this.password = email;
}
//OR maybe this:
public void setPassword(String password) {
this.password = password;
}
Hope that helps
Amber
[This message has been edited by Amber Woods (edited May 25, 2001).]


"Happiness is a way to Travel, <b>Not</b> a Destination" -- Unknown
Kavita Ghia
Ranch Hand

Joined: Oct 10, 2000
Posts: 91
Hey Amber,
That certainly is a mistake not supposed to be repeated.Thanks for the pointer.
Kavita.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what's wrong
 
Similar Threads
Problem with jsp:useBean tag...URGENT
Struts 2 cannot retrieve java bean object
HTTP ERROR: 500
HTTP ERROR: 500
Can you have a String type method return two String values, or do I need to use String array?