The value for the useBean class attribute action.TestBean is invalid. How to correct it?

427 views Asked by At

So I was making a simple JSP code to work with Java Beans which I directly took from tutorialspoint.com This is the file which is TestBean.java which is just simply giving this message.

package action;

public class TestBean {
private String message = "No message specified";

public String getMessage() {
   return(message);
}
public void setMessage(String message) {
  this.message = message;
}
}

The main.jsp is like this which is just initiating the .java file.

    <html>
    <head>
    <title>Using JavaBeans in JSP</title>
    </head>
    <body>
    <center>
   <h2>Using JavaBeans in JSP</h2>
 <jsp:useBean id="test" class="action.TestBean" />

 <jsp:setProperty name="test" 
                   property="message" 
                   value="Hello JSP..." />

  <p>Got message....</p>

     <jsp:getProperty name="test" property="message" />

   </center>
   </body>
   </html>

The error that is coming is

 type Exception report

 message /main2.jsp (line: 9, column: 0) The value for the useBean class attribute action.TestBean is invalid.

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

exception
org.apache.jasper.JasperException: /main2.jsp (line: 9, column: 0) The value for the useBean class attribute action.TestBean is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:275)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:107)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1317)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1178)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
org.apache.jasper.compiler.Node$Root.accept(Node.java:464)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Generator.generate(Generator.java:3594)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:250)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

Can anyone please help me out? It seems a very basic doubt.

0

There are 0 answers