• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using The UseBean from Jsp

 
Praveen
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! Friends,
I have a jsp page using the <jsp:useBean>
property and have a BeanClass .
Also i have the package etc.
I have placed the jsp file in Jsp folder
and the BeanClass in pakage.
Tomcat gives me the following error:-
org.apache.jasper.JasperException: Unable to compile class for JSP
C:\jtomcat\work\Standalone\localhost\zz\jsp\numguess$jsp.java:3: Class num.NumberGuessBean not found in import.
import num.NumberGuessBean;
^
1 error
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:285)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:548)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:176)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:188)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:479)

The Code ends here.
--Thank's in advance.
Praveen
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to put num.NumberGuessBean in the CLASSPATH. Tomcat can't compile the jsp because it can't find num.NumberGuessBean.
If num.NumberGuessBean is in a jar file then that jar file must be in your CLASSPATH.
If num.NumberGuessBean is not in a jar file then the directory above "num" must be in your CLASSPATH.
For example, in Tomcat, you would usually have NumberGuessBean.class in the "WEB-INF/classes/num/" directory of your web app. Tomcat automatically knows about the "classes" directory so you shouldn't need to add it explicitly to its CLASSPATH.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, not the CLASSPATH, the web application classes should not depend on the classpath

Since a JSP becomes a servlet, and every class used in a servlet should be in WEB-INF/classes or WEB-INF/lib, you should have
WEB-INF/classes/num/NumberGuessBean.class
Be sure to name the complete package and class in your <jsp:useBean tag in addition to the import statement.
Bill
 
Praveen
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes!
Thank's for the answer.
I have the code running.
Thank's once again.
--Praveen
 
pavitra nagaraja
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Praveen,
How did you get this NumberGuessBean to run? I'm trying to do the same thing, I have the classes in web-inf/classes/num. I have used USE_BEAN directive aslo. But I get the same error you were getting
Thanks
Pavitra
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!