Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
| Search | Today's Posts | Mark Forums Read
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 16th, 2006, 10:29 AM
Registered User
 
Join Date: Aug 2006
Location: , , United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with classes

Hello,

I am new to JavaServer pages, and I am having trouble getting both servlets and jsp to work on Tomcat 5.5

I can get jsp pages to run ok, but whenever I use the <jsp:usebean tag with a class of my own, I get the following error:

org.apache.jasper.JasperException: /hannah/test.jsp(2,0) The value for the useBean class attribute beans.Team is invalid.
    org.apache.jasper.servlet.JspServletWrapper.handle JspException(JspServletWrapper.java:510)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:375)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)


root cause

org.apache.jasper.JasperException: /hannah/test.jsp(2,0) The value for the useBean class attribute beans.Team is invalid.
    org.apache.jasper.compiler.DefaultErrorHandler.jsp Error(DefaultErrorHandler.java:39)
    org.apache.jasper.compiler.ErrorDispatcher.dispatc h(ErrorDispatcher.java:405)
    org.apache.jasper.compiler.ErrorDispatcher.jspErro r(ErrorDispatcher.java:146)
    org.apache.jasper.compiler.Generator$GenerateVisit or.visit(Generator.java:1174)
    org.apache.jasper.compiler.Node$UseBean.accept(Nod e.java:1116)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.j ava: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.j ava:456)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.j ava:2163)
    org.apache.jasper.compiler.Generator.generate(Gene rator.java:3305)
    org.apache.jasper.compiler.Compiler.generateJava(C ompiler.java:198)
    org.apache.jasper.compiler.Compiler.compile(Compil er.java:295)
    org.apache.jasper.compiler.Compiler.compile(Compil er.java:276)
    org.apache.jasper.compiler.Compiler.compile(Compil er.java:264)
    org.apache.jasper.JspCompilationContext.compile(Js pCompilationContext.java:563)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:303)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)


I have tried everything I can think of to fix it. I packaged the file correctly.

My CLASSPATH environment variable reads like this:

C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar;C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\jsp-api.jar;C:\Javafiles\beans;.

JAVA_HOME:

C:\Java\jdk1.5.0_08

PATH:

C:\Java\jdk1.5.0_08\bin

CATALINA_HOME is this:

C:\Program Files\Apache Software Foundation\Tomcat 5.5


The code for my bean reads like this:

package beans;

public class Team {

String name, manager;

public void setName(String name) {

this.name = name;

}

public String getName() {

return name;

}

public void SetManager(String manager) {
this.manager = manager;
}

public String getManager() {
return manager;

}


}


And here is my jsp code


<jsp:useBean id="t" scope="session" class="beans.Team"/>
<jsp:getProperty name="t" property="name"/>
<jsp:getProperty name="t" property="manager"/>


<html>
<body>
<FORM>
<INPUT TYPE="text" NAME="name">
<INPUT TYPE="text" NAME="manager">

</FORM>



</body>
</html>


I think it may be to do with the class not being found, but I have added it to the classpath.

What am I doing wrong?

Thanks

Hannah



  #2 (permalink)  
Old August 16th, 2006, 05:51 PM
Friend of Wrox
 
Join Date: Jan 2006
Location: San Francisco, CA, USA.
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The message "The value for the useBean class attribute ..." means that a no-argument constructor is not available. One would think that since you don't have a constructor defined, a no-arg constructor would exist by default. But maybe you've simplified the example you gave, or perhaps you really do need to define the no-arg constructor. Give it a try! :)

Jon Emerson
http://www.jonemerson.net/
  #3 (permalink)  
Old August 17th, 2006, 04:58 AM
Registered User
 
Join Date: Aug 2006
Location: , , United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Thanks for your reply. I assumed that because there were no other constructors, it would implicitly use a default one, but even so I did try that before, but still got the same error.

Hannah



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in calling classes in simple Servlet sanna231 J2EE 6 December 23rd, 2012 01:06 AM
HELP Problem With Classes nichola_x_rose ASP.NET 2.0 Basics 1 March 18th, 2007 03:35 AM
HELP Problem With Classes nichola_x_rose ASP.NET 2.0 Professional 0 March 17th, 2007 07:56 AM
Problem with the namespace & classes ayamas .NET Framework 2.0 2 November 25th, 2006 02:13 PM
Problem with Classes Tonper C# 2 November 22nd, 2004 08:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.