• Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaBean Problem

 
Narasimha Reddy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using Tomcat 4.1.10. I am Created simple java file and its class file placed in C:\Tomcat\webapps\examples\WEB-INF\classes,
the jsp file placed in C:\Tomcat\webapps\examples

After running the jsp file i got message like

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

An error occurred at line: 6 in the jsp file: /Beantest.jsp

Generated servlet error:
[javac] Compiling 1 source file

C:\Tomcat\work\Standalone\localhost\examples\Beantest_jsp.java:44: cannot resolve symbol
symbol : class SimpleBean
location: class org.apache.jsp.Beantest_jsp
SimpleBean test = null;
^



An error occurred at line: 6 in the jsp file: /Beantest.jsp

Generated servlet error:
C:\Tomcat\work\Standalone\localhost\examples\Beantest_jsp.java:46: cannot resolve symbol
symbol : class SimpleBean
location: class org.apache.jsp.Beantest_jsp
test = (SimpleBean) pageContext.getAttribute("test", PageContext.PAGE_SCOPE);
^



An error occurred at line: 6 in the jsp file: /Beantest.jsp

Generated servlet error:
C:\Tomcat\work\Standalone\localhost\examples\Beantest_jsp.java:49: cannot resolve symbol
symbol : class SimpleBean
location: class org.apache.jsp.Beantest_jsp
test = (SimpleBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "SimpleBean");
^
3 errors


at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:340)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:184)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
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:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
at java.lang.Thread.run(Thread.java:536)

------------------------------------------------------
The java file is :SimpleBean.java
public class SimpleBean {
private String message = "No message specified";
public SimpleBean(){

}
public String getMessage() {
return(message);
}
public void setMessage(String message) {
this.message = message;
}
}
---------------------------------------------------
The jsp file is: BeanTest.jsp

<HTML>
<BODY>
<jsp:useBean id="test" class="SimpleBean" />
<jsp:setProperty name="test" property="message" value="hi"/>
<%=test.getMessage()%>
</BODY>
</HTML>

Thanks for reply...........

Narasimha Reddy
SCJP1.4
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your beans need to be in a package
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!