aspose file tools*
The moose likes Servlets and the fly likes Error using beans and JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Error using beans and JSP" Watch "Error using beans and JSP" New topic
Author

Error using beans and JSP

anuja parikh
Greenhorn

Joined: May 07, 2001
Posts: 6
Hi!
I m new to JSP and beans and was just trying out the sample example from tutorials. But i got struck using beans and JSP..
1. Initially i wrote an html using button and textfields and on
clicking on that button should open a jsp page named
SaveName.jsp
2. I wrote a bean class named UserData and wrote all get and set methods required.
3. I then wrote a JSP named SaveName.jsp and coded something like this..
<jsp:useBean id="user" class="UserData" scope="session"/>
<jsp:setProperty name="user" property="*"/>
<html>
<body>
<A href="NextPage.jsp"> Continue </A>
</body>
</html>
4. The coding of NextPage.jsp is something like this..
<jsp:useBean id="user" class="UserData" scope="session"/>
-------including other html tags...
I initially kept my all files in c:\tomcat\webapps\examples\jsp
directory and also compiled my bean UserData.java file here...but i got the error message when i clicked on button and my SaveName.jsp couldnt be opened to store the data..
The error is as follows :
org.apache.jasper.JasperException: Unable to compile class for JSPC:\TOMCAT\bin\..\work\localhost\examples\jsp\SaveName_jsp.java:57: Class org.apache.jsp.UserData not found.
UserData user = null;
^
C:\TOMCAT\bin\..\work\localhost\examples\jsp\SaveName_jsp.java:60: Class org.apache.jsp.UserData not found.
user= (UserData)
^
C:\TOMCAT\bin\..\work\localhost\examples\jsp\SaveName_jsp.java:65: Class org.apache.jsp.UserData not found.
user = (UserData) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "UserData");
^
3 errors
I also tried to keep my class files in
c:\tomcat\webapps\examples\web-inf\classes directory but the same error follows...
Can anyone help me to solve this problem....
Thanks in advance
anuja

kichu kichu
Ranch Hand

Joined: May 10, 2001
Posts: 59
Hai anuja,
That was cute!!.Can u post your code for UserData.java also.
The problem seems to be there.
regards,
kichu.
anuja parikh
Greenhorn

Joined: May 07, 2001
Posts: 6
The code for my UserData is as follows:
public class UserData {
String username;
String email;
int age;
public void setUsername( String value ){
username = value;
}
public void setEmail( String value )
{
email = value;
}
public void setAge( int value )
{
age = value;
}
public String getUsername() { return username; }
public String getEmail() { return email; }
public int getAge() { return age; }
}
mohana konakanchi
Ranch Hand

Joined: May 16, 2001
Posts: 67
Hi,
If your are creating a bean with in some package. you need to write that package name when ever you are trying access bean
or you need to import that package.
vik nuckchady
Greenhorn

Joined: Apr 25, 2001
Posts: 25
The error is in your page SaveName.jsp
Add the following as the first line:

Cheers
anuja parikh
Greenhorn

Joined: May 07, 2001
Posts: 6
Thanks a lot for this help...i could solve out the problem...
anuja
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error using beans and JSP