Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

compiling bean

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Hi iam new to jsp.Iam following instructions given in the below links to compile UserData.java bean.But iam getting an error when i compile the bean.
http://www.jsptut.com/Forms.jsp
http://www.jsptut.com/Classpath.html
Iam using j2sdk1.4.2_03.

ERROR:Cannot read UserData.java file

Thanks
Lakshmi
 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lakshmi,
Try putting the Bean Class (UserData) in WEB-INF\classes directory and make sure it is in the classpath.
Also, if you are using 'Tomcat 5', the bean class has to be inside a package.

You have to import only packages. For example, in JSP, you can no longer have <%@page import="someClass"%>. It has to be inside a package. You can only have <%@page import ="somePckg.someClass" %>
Otherwise, it'll give exception "."expected


Regards,
Nandini
[ October 09, 2004: Message edited by: Nandini Sriram ]
 
Lakshmi siri
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nandini,
Thank u for resonse. The class file is created for UserData bean.I put that class file Web_inf /Classes.When i run on tomcat server i am getting the following error.


HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 1 in the jsp file: /SaveNam.jsp
Generated servlet error:
C:\jakarta-tomcat-5.0.28\work\Catalina\localhost\_\org\apache\jsp\SaveNam_jsp.java:42: cannot access org.apache.jsp.UserData


An error occurred at line: 1 in the jsp file: /SaveNam.jsp
Generated servlet error:
bad class file: C:\jakarta-tomcat-5.0.28\webapps\ROOT\WEB-INF\classes\org\apache\jsp\UserData.class
class file contains wrong class: UserData
Please remove or make sure it appears in the correct subdirectory of the classpath.
UserData user = null;
^
1 error



org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.


Thanks
Lakshmi
 
Nandini Sriram
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lakshmi,

Put the UserData inside a package, say "myPack" and put this inside the /WEB-INF/classes folder.
In your JSP pages, import the package itself -
<jsp:useBean id="user" class="myPack.UserData" scope="session"/>
Please check your JSP page for any errors!!
Let me know if you have any problems.

Regards,
Nandini
[ October 11, 2004: Message edited by: Nandini Sriram ]
 
Lakshmi siri
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nandini,

I created mypack package.i modified
<jsp:useBean id="user" class="mypack.UserData" scope="session"/>
.When iam ruuning on Tomcat server iam getting the following error

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /SaveNam.jsp(1,1) The value for the useBean class attribute mypack.UserData is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:150)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1227)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Generator.generate(Generator.java:3272)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.

Thanks
Lakshmi
 
Nandini Sriram
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lakshmi,

I just tried it out and it seems to be working properly. Maybe you have some problem in classpath. Just check if you have the WEB-INF/classes folder in the correct path. Also this bean file inside
WEB-INF/classes/myPack/UserData.class. Check for the correct package name too.
I found a link where someone had the same problem. Hope it solves yours too!!
http://forums.devshed.com/t44539/s.html
Let me know if you have more problems.

Regards,
Nandini
[ October 11, 2004: Message edited by: Nandini Sriram ]
 
Lakshmi siri
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nandini,

Now i got it.Thanks for your help.

-Lakshmi
 
It looks like it's time for me to write you a reality check! Or maybe a tiny ad!
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic