GeeCON Prague 2014*
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
Author

JSP validation

c york
Greenhorn

Joined: Mar 16, 2006
Posts: 28
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("jdbcdbc: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 {

}
Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401
Hi.

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
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

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] [Bear's FrontMan] [About Bear] [Books by Bear]
Hussam Bamatraf
Greenhorn

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: 3344

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]
 
GeeCON Prague 2014
 
subject: JSP validation