• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP validation

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am writing an application in jsp. I'm a beginner and having a problem with the validation page. I created a bean and the class is user.login. I got this code from a web site and it did not explain the class that was created completely. If there is someone who can assist, I would appreciate it.

Validate.jsp - error :user cannot resolve to a type - line 2

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<jsp:useBean id="idHandler" class="user.login" scope="request">
<jsp:setProperty name="idHandler" property="*"/>
</jsp:useBean>

<%
if (idHandler.validate()) {
%>
<jsp:forward page="success.jsp"/>
<%
} else {
%>
<jsp:forward page="retry.jsp"/>
<%
}
%>

************************************************
//user(class)

package user;
import java.sql.*;

public class Login {

// private String username = "";
private String password = "";

public Login() {
}
public void setPassword(String password) {
this.password = password;
}
//public void setUsername(String username) {
// this.username = username;
// }

public boolean authenticate(String username2,
String password2) {
// String query="select * from Registration;";
//String DbUserName="";
//String DbPassword="";
//String finalUser="";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
con=DriverManager.getConnection("jdbc:odbc:register");
Statement stat=con.createStatement();
ResultSet rst=stat.executeQuery(query);
while(rst.next())

{
// DbUserName=rst.getString("UserName");

//DbPassword=rst.getString("password");

//if (username2.equals(DbUserName) &&
//password2.equals(DbPassword)) {

break;
}


}
return true;
}catch(Exception e){

e.printStackTrace();
return false;
}
}}



public class login {

}
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.

It looks like your jsp can't find login class. Are you sure it's in the classpath?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The site you got this code from must be fairly old. Doing validation like this in a JSP is very old-fashioned and frowned upon with regards to modern web application patterns. Any such processing should be done in a servlet, not a JSP.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


<jsp:useBean id="idHandler" class="user.login" scope="request">


In the above line, the class name is not correct. It should be . [Notice the capital letter L].
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, that might be the reason.

Check your FQCN (Fully Qualified Class Name) when you specify the type.

also make sure the class is visible to the container at the runtime (if its in the classpath).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic