My group is working on a vendor type based website for a software
engineering engineering course. We have little to no experience in
java or jsp. Most of the knowledge we know about the languages has
been absorbed from tutorials from the interenet in the past few weeks.
Now on to our troubles. We're trying to design a log-in page were
users of our website can log in to utilize our service. The tutorial
we're using comes from http://www.jsptut.com sections 9 and 10.
Heres snippets of our code:
************************************************************
this is from login.jsp:
<p align="center">Login:</p>
<form method="POST" action="auth.jsp">
<p align="center">
Username:
<INPUT TYPE=TEXT name="username" size="20"><br><br>
Password:
<input type=PASSWORD name="upassword" size="20"><br><br>
<input type=SUBMIT>
</p>
</form>
************************************************************
this is from auth.jsp:
<jsp:useBean id="user" class="UserData" scope="session"/>
<jsp:setProperty name="user" property="*"/>
<HTML>
<HEAD><TITLE>BookWorms - Authenticating...</TITLE></HEAD>
<BODY>
<%
Connection dbconn;
PreparedStatement sql;
try{
Class.forName("org.gjt.mm.mysql.Driver");
try{
String name;
boolean doneheading = false;
dbconn=DriverManager.getConnection("jdbc:mysql://localhost/group10","group10","password");
Statement statement = dbconn.createStatement();
String query = "SELECT * FROM members WHERE
username = 'lmachado'";
ResultSet rs;
rs = statement.executeQuery(query);
while(rs.next()){
String dpass =
rs.getString("upassword");
String upass = user.getUpassword();
out.println(upass);
out.println(dpass);
if(dpass.equals(upass))
out.println("good
password<br>");
else
out.println("bad
password<br>");
}
}
catch (SQLException s){
out.println("SQL Error<br>" + s.getMessage());
}
}
catch (ClassNotFoundException err){
out.println("Class loading error");
}
}
************************************************************
here is our class:
package UserData;
public class UserData {
String username;
String upassword;
public void setUsername(String value){
username = value;
}
public void setUpassword(String value){
upassword = value;
}
public String getUsername(){
return username;
}
public String getUpassword(){
return upassword;
}
}
**************************************************************
When we try to log in using our page, tomcat gives these errors:
org.apache.jasper.JasperException: UserData (wrong name:
UserData/UserData)
javax.servlet.ServletException: UserData (wrong name:
UserData/UserData)
We're clueless on where to begin how to debug this and what these
errors even mean. Again, we have no experience with programming in jsp
or java. Thanks in advanced.
littlewild@gmail.com - 31 Mar 2005 03:47 GMT
The jsp:useBean tag requires a fully qualified class name. Meaning you
have to include the package name of the class too. In your case it will
be UserData.UserData
If you want to change the property of the bean, you need to place the
setProperty tag within the body of the useBean tag. Note that useBean
will only change the value of the bean only if it instantiates it.
For more info, see
http://java.sun.com/products/jsp/tags/11/syntaxref11.fm14.html