Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP and BEANS

 
vasudha prabhala
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the following are the three files that I am using and i get the following message
GetName.html
<HTML>
<BODY>
<FORM METHOD=POST ACTION="SaveName1.jsp">
What's your name? <INPUT TYPE=TEXT NAME=username SIZE=20><BR>
What's your e-mail address? <INPUT TYPE=TEXT NAME=email SIZE=20><BR>
What's your age? <INPUT TYPE=TEXT NAME=age SIZE=4>
<P><INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>
Savename1.jsp
<jsp:useBean id="user" class="UserData" scope="session"/>
<jsp:setProperty name="user" property="*"/>
<HTML>
<BODY>
<A HREF="NextPage1.jsp">Continue</A>
</BODY>
</HTML>
NextPage1.jsp

<jsp:useBean id="user" class="UserData" scope="session"/>
<HTML>
<BODY>
You entered<BR>
Name: <%= user.getUsername() %><BR>
Email: <%= user.getEmail() %><BR>
Age: <%= user.getAge() %><BR>
</BODY>
</HTML>
I have my class UserDate.Class in c:\myfolder\myclasses. and I have added this to the classpath. I am using tomcat 3.3.1 and JDK 1.4 is installed on my system. I am using servlet 2.2 and jsp 1.1 . why am I getting the following error.. please help..
Error: 500
Location: /examples/jsp/myfiles/SaveName1.jsp
Internal Servlet Error:
org.apache.jasper.JasperException: Unable to compile Note: sun.tools.javac.Main has been deprecated.
C:\vasudha\tomcat\jakarta-tomcat-3.3.1\work\DEFAULT\examples\jsp\myfiles\SaveName1_1.java:52: Class jsp.myfiles.UserData not found.
UserData user = null;
^
C:\vasudha\tomcat\jakarta-tomcat-3.3.1\work\DEFAULT\examples\jsp\myfiles\SaveName1_1.java:55: Class jsp.myfiles.UserData not found.
user= (UserData)
^
C:\vasudha\tomcat\jakarta-tomcat-3.3.1\work\DEFAULT\examples\jsp\myfiles\SaveName1_1.java:60: Class jsp.myfiles.UserData not found.
user = (UserData) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "UserData");
^
3 errors, 1 warning
at org.apache.tomcat.facade.JasperLiaison.javac(JspInterceptor.java:898)
at org.apache.tomcat.facade.JasperLiaison.processJspFile(JspInterceptor.java:733)
at org.apache.tomcat.facade.JspInterceptor.requestMap(JspInterceptor.java:506)
at org.apache.tomcat.core.ContextManager.processRequest(ContextManager.java:968)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:875)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
 
Deepak MP
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have my class UserDate.Class in c:\myfolder\myclasses. and I have added this to the classpath. I am using tomcat 3.3.1 and JDK 1.4 is installed on my system. I am using servlet 2.2 and jsp 1.1 . why am I getting the following error.. please help..
PUT THE UserData.class in WEB-INF FOLDER.
DEEPAK
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has got to be one of the most common problems with JSP. To avoid bizarre problems like this - instead of:
<jsp:useBean id="user" class="UserData" scope="session"/>
You MUST put your class in a package and include the package name in the tag:
<jsp:useBean id="user" class="mypkg.UserData" scope="session"/>
You MUST also import the package and put the class files under WEB-INF/classes just like servlet classes.
The reason is that without a package, the compiler and servlet engine will look in the "current" directory - you have not control over what the "current" directory is.
Bill
[ January 11, 2003: Message edited by: William Brogden ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic