Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

JSP validation

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hi.

It looks like your jsp can't find login class. Are you sure it's in the classpath?
 
Marshal
Posts: 67366
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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).
 
bacon. tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!