File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes compiling  bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "compiling  bean" Watch "compiling  bean" New topic
Author

compiling bean

Lakshmi siri
Ranch Hand

Joined: Feb 06, 2004
Posts: 44
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
Nandini Sriram
Ranch Hand

Joined: Jul 04, 2003
Posts: 132
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 ]

Discipline, Dedication and Determination define Destiny.
Lakshmi siri
Ranch Hand

Joined: Feb 06, 2004
Posts: 44
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

Joined: Jul 04, 2003
Posts: 132
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

Joined: Feb 06, 2004
Posts: 44
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

Joined: Jul 04, 2003
Posts: 132
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

Joined: Feb 06, 2004
Posts: 44
Hi Nandini,

Now i got it.Thanks for your help.

-Lakshmi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compiling bean