File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes JSP validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP validation" Watch "JSP validation" New topic

JSP validation

c york
Ranch Hand

Joined: Mar 16, 2006
Posts: 31
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="*"/>

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


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 {
Statement stat=con.createStatement();
ResultSet rst=stat.executeQuery(query);

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


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


return true;
}catch(Exception e){

return false;

public class login {

Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401

It looks like your jsp can't find login class. Are you sure it's in the classpath?

Leandro Melo
SCJP 1.4, SCWCD 1.4
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

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.

[Asking smart questions] [About Bear] [Books by Bear]
Hussam Bamatraf

Joined: Aug 25, 2003
Posts: 14

<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].

SCJP 90%<br />FileNet Certified Professional: Content Management Developer 92%<br />FileNet Certified Professional: Business Process Management Developer 92%
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3381

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).

Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
I agree. Here's the link:
subject: JSP validation
It's not a secret anymore!