• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error using beans and JSP

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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; }
}
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error is in your page SaveName.jsp
Add the following as the first line:

Cheers
 
anuja parikh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for this help...i could solve out the problem...
anuja
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic