aspose file tools*
The moose likes Tomcat and the fly likes JSP BEAN Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "JSP BEAN Question" Watch "JSP BEAN Question" New topic
Author

JSP BEAN Question

Amar Naik
Ranch Hand

Joined: Sep 26, 2003
Posts: 43
Hi,

I am trying to develop a simple JSP+Bean application. I am using Tomcat application.

I have placed my JSP in apache-tomcat-6.0.10\webapps\test.
Added <Context path="/test" docBase="star" debug="1" reloadable="true"/>
in server.xml

Here is my JSP code


here is my JAVA code


i compiled the java code and placed the class file in apache-tomcat-6.0.10\webapps\ROOT\WEB-INF\classes\com\stardeveloper\bean\test.

when i try to run the JSP page , i get an error which mentions "The value for the useBean class attribute com.stardeveloper.bean.test.NumberGuessBean is invalid."

Please advise
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

I have placed my JSP in apache-tomcat-6.0.10\webapps\test.


i compiled the java code and placed the class file in apache-tomcat-6.0.10\webapps\ROOT\WEB-INF\classes\com\stardeveloper\bean\test.


You put the bean in one web application, and the JSP in another. Of course they're not going to hook up to each other.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Amar Naik
Ranch Hand

Joined: Sep 26, 2003
Posts: 43
yeah i realized it

I put my class file in apache-tomcat-6.0.10\webapps\test\WEB-INF\classes

In JSP i changed the below details

<%@ page import = "NumberGuessBean" %>

<jsp:useBean id="numguess" class="NumberGuessBean" scope="session"/>

But i still get the same error. did i do it properly now?
Amar Naik
Ranch Hand

Joined: Sep 26, 2003
Posts: 43
i removed the package details from java code. I recompiled the code and i get the following error now

org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:600)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:142)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Originally posted by Amar Naik:
i removed the package details from java code.


Why? That pretty much guarantees that the bean will never be found. It must be in a package.

See the JSP FAQ for details.
[ May 02, 2007: Message edited by: Bear Bibeault ]
Amar Naik
Ranch Hand

Joined: Sep 26, 2003
Posts: 43
I am sorry, i am getting confused

My java file is in apache-tomcat-6.0.10\webapps\test\WEB-INF\classes
and jsp file is in apache-tomcat-6.0.10\webapps\test

do i still need a package? If yes what should be the package details
Amar Naik
Ranch Hand

Joined: Sep 26, 2003
Posts: 43
i restarted the server and got my application running
I did create a new folder called a in classes directory, added the package details in java code, recompiled , restarted the server

it works now

thanks for the help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP BEAN Question