• Post Reply Bookmark Topic Watch Topic
  • New Topic

Please help on this newbie jsp compile problem

 
xue shen
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.

An error occurred at line: 3 in the jsp file: /site/test3.jsp
Generated servlet error:
c:\j2sdkee1.3.1\repository\CPQ31978881985\web\site\test3$jsp.java:65: Class org.apache.jsp.Login not found.
Login login = null;
^

An error occurred at line: 3 in the jsp file: /site/test3.jsp
Generated servlet error:
c:\j2sdkee1.3.1\repository\CPQ31978881985\web\ site\test3$jsp.java:68: Class org.apache.jsp.Login not found.
login= (Login)
^

An error occurred at line: 3 in the jsp file: /site/test3.jsp
Generated servlet error:
c:\j2sdkee1.3.1\repository\CPQ31978881985\web\ site\test3$jsp.java:73: Class org.apache.jsp.Login not found.
login = (Login) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "Login");
^
3 errors, 1 warning
the login file is a bean file that validates the field, test 3 is to show that validation is ok
here are the codes
package bean;
import java.io.*;
import java.sql.*;
public class Login{
private String username="";
private String password ="";
private boolean val;
Connection con =null;
Statement stat = null;
ResultSet rs=null;
public void setUsername(String username){
this.username = username;
}
public void setPassword(String password){
this.password = password;
}
public String getUsername(){
return username;
}
public String getPassword(){
return password;
}
public Login() throws ClassNotFoundException{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
public boolean isValid(){
val = false;
String password2="";
try{
username = getUsername();
password = getPassword();
con=DriverManager.getConnection("jdbc dbc:forumUser","","");
String query="Select password from ForumUser where username='"+username+"'";
stat = con.createStatement();
rs = stat.executeQuery(query);
while(rs.next()){
password2 = rs.getString(1);
}
password = password.trim();
password2 = password2.trim();
if(password2.equals(password)){
val = true;
}
}catch(Exception e){
System.out.println("SQL Exception is caught.");
}
return val;
}
}
here is the test3.jsp:
<%@ page import="java.util.*"%>
<%@ page language ="java" %>
<jsp:useBean id="login" scope ="application" class="Login" />
<jsp:setProperty name ="login" property ="username" param="username"/>
<jsp:setProperty name="login" property="password" param="password"/>
<html>
<head><title>Result page</title></head>
<h2>The Reult Page</h2><hr><hr>
<body bgcolor="#ffdfd7">
<%
String username = login.getUsername();
String password = login.getPassword();
boolean validate = login.isValid();
if(validate == true){
out.println("<h3>" + "Your login has been validated"+"</h3>");
}else{
out.println("<h3>"+"Not a valid login, please register!" +"</h3>");
}
%>
</body>
</html>
 
Dan Richardson
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try changing the following line:
<jsp:useBean id="login" scope ="application" class="Login" />

To this:
<jsp:useBean id="login" scope ="application" class="bean.Login" />

Your Login class is in a package named bean. When referencing this class, you need to use the package.class syntax, hence, bean.Login
 
xue shen
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dan,
It works great now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!