First I put my java files in apache server WEB-INF/classes/...
There is one simple java I made:
package Promotion;
public class User{
private String ID;
private String email;
private String firstName;
private String lastName;
/** Creates a new instance of user */
public User() {
this.ID = null;
this.email = null;
this.firstName = null;
this.lastName = null;
}
public String getID(){
return this.ID;
}
public void setID(String ID){
this.ID = ID;
}
public String getEmail(){
return this.email;
}
public void setEmail(String email){
this.email = email;
}
public String getFirstName(){
return this.firstName;
}
public void setFirstName(String firstName){
this.firstName = firstName;
}
public String getLastName(){
return this.lastName;
}
public void setLastName(String lastName){
this.lastName = lastName;
}
}
Then I use Bean in my JSP as follow:
<jsp:useBean id="User" class="Promotion.User" scope="session">
<%
User a = new User();
%>
</jsp:useBean>
After that I try to compile my JSP page. But error comes out:
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 5 in the jsp file: /test/new/promotion/draw.jsp
Generated servlet error:
[javac] Compiling 1 source file
/usr/local/tomcat/work/Standalone/accupc.com/_/test/new/promotion/draw_jsp.java:54: package Promotion does not exist
Promotion.User User = null;
^
An error occurred at line: 5 in the jsp file: /test/new/promotion/draw.jsp
Generated servlet error:
/usr/local/tomcat/work/Standalone/accupc.com/_/test/new/promotion/draw_jsp.java:56: package Promotion does not exist
User = (Promotion.User) pageContext.getAttribute("User", PageContext.SESSION_SCOPE);
^
An error occurred at line: 5 in the jsp file: /test/new/promotion/draw.jsp
Generated servlet error:
/usr/local/tomcat/work/Standalone/accupc.com/_/test/new/promotion/draw_jsp.java:59: package Promotion does not exist
User = (Promotion.User) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "Promotion.User");
^
An error occurred at line: 26 in the jsp file: /test/new/promotion/draw.jsp
Generated servlet error:
/usr/local/tomcat/work/Standalone/accupc.com/_/test/new/promotion/draw_jsp.java:94: package Promotion does not exist
Promotion.User [] customer = new Promotion.User[totalID];
^
An error occurred at line: 26 in the jsp file: /test/new/promotion/draw.jsp
Generated servlet error:
/usr/local/tomcat/work/Standalone/accupc.com/_/test/new/promotion/draw_jsp.java:94: package Promotion does not exist
Promotion.User [] customer = new Promotion.User[totalID];
^
An error occurred at line: 26 in the jsp file: /test/new/promotion/draw.jsp
Generated servlet error:
/usr/local/tomcat/work/Standalone/accupc.com/_/test/new/promotion/draw_jsp.java:105: cannot resolve symbol
symbol : class User
location: class org.apache.jsp.draw_jsp
customer[counter] = new User();
^
An error occurred at line: 49 in the jsp file: /test/new/promotion/draw.jsp
Generated servlet error:
/usr/local/tomcat/work/Standalone/accupc.com/_/test/new/promotion/draw_jsp.java:117: cannot resolve symbol
symbol : class User
location: class org.apache.jsp.draw_jsp
User [] winner = new User[10];
^
An error occurred at line: 49 in the jsp file: /test/new/promotion/draw.jsp
Generated servlet error:
/usr/local/tomcat/work/Standalone/accupc.com/_/test/new/promotion/draw_jsp.java:117: cannot resolve symbol
symbol : class User
location: class org.apache.jsp.draw_jsp
User [] winner = new User[10];
^
8 errors
-
Cannot find my JeanBean when compile my JSP page (2 messages)
- Posted by: Eric So
- Posted on: May 24 2004 13:51 EDT
Threaded Messages (2)
- Cannot find my JeanBean when compile my JSP page by Joe Attardi on May 24 2004 15:56 EDT
- It works! by Eric So on May 27 2004 13:26 EDT
-
Cannot find my JeanBean when compile my JSP page[ Go to top ]
- Posted by: Joe Attardi
- Posted on: May 24 2004 15:56 EDT
- in response to Eric So
Hi Eric.
Do you have the User bean in the right directory under your WEB-INF/classes directory?
Since you have a package declaration of 'package Promotion', it should be in:
WEB-INF/classes/Promotion/User.class
and not
WEB-INF/classes/User.class
Also, just FYI, the usual standard is for package names to be all lowercase. But this wouldn't affect your application, just a stylistic choice.
Check if it's in the right directory and see if that works...
-- Joe -
It works![ Go to top ]
- Posted by: Eric So
- Posted on: May 27 2004 13:26 EDT
- in response to Eric So
Thanks for the suggestion. I feel so sorry that I remember I have to restart the web server. Hehe