From what I saw of the source the last time someone had trouble with useBean, it uses reflection to come up with the class. The useBean tag is a compiled class already and as such probably doesn't have any knowlege of the import directive.

--David

Frederik Gottlieb wrote:

Thanks for the advice, but lets leave the java.lang.String alone (remember that it works if I fully qualify the package name)

I have a bean defined, dk.releaze.service.web.smsbulk.beans.Customer, that is a public class with a public no-arg constructor with public accessors and mutators - ie. a bean.
I use the bean on the page with,
   <%@ page import="dk.releaze.service.web.smsbulk.beans.*" %>
   ...
   <jsp:useBean id="customer" class="Customer" scope="session" />
and it fails like described below.

If I change the useBean to
<jsp:useBean id="customer" class="dk.releaze.service.web.smsbulk.beans.Customer" scope="session" />
it works with no problem.

It seems to me that Jasper doesn't look at the <%@ page import .. %> directive, or perhaps something else is missing.

/Frederik Gottlieb

David Smith skrev:

The class specified in the useBean tag must be a valid bean. java.lang.String is not a valid bean. Why don't you just use the request attribute directly and omit the <jsp:useBean .../>? Example: <p>Login failed value is ${loginFailed}</p>

Resin may be lax on this point, but tomcat 5.5 is a fair stickler on this.

--David

Frederik Gottlieb wrote:

Hi,

I'm new to Tomcat, but have been using Resin 2.1.16 for quite some time now. We are in the process of upgrading our server software, and we would like to test out the new Tomcat 5.5.20, but I seem to get some problems. We are moving our existing (working) applications to a test server, now installed with Tomcat instead of Resin - every thing works fine under Resin.

In our JSP files we are using beans, and they are typically declared as

   ...
   <jsp:useBean id="loginFailed" class="String" scope="request" />
   (line 6 of the JSP source file)
   ...

Now this of cause refers to the java.lang.String class.
If I deploy this file I get the following exception in Tomcat

   type Exception report

   message

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

   exception

   org.apache.jasper.JasperException: /jsp/da_DK_RELEAZE/index.jsp(6,0)
   The value for the useBean class attribute String is invalid.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
dk.releaze.servlet.http.RealtimeHttpServlet.gotoPage(Unknown Source) dk.releaze.service.web.smsbulk.servlets.Index.doGetRequest(Index.java:75) dk.releaze.servlet.http.RealtimeHttpServlet.doGet(Unknown Source)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
dk.releaze.servlet.http.RealtimeHttpServlet.service(Unknown Source)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

   root cause

   org.apache.jasper.JasperException: /jsp/da_DK_RELEAZE/index.jsp(6,0)
   The value for the useBean class attribute String is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146) org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1174)
       org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
       org.apache.jasper.compiler.Node$Nodes.visit(Node.java: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.java:456)
       org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Generator.generate(Generator.java:3320) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
       org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
       org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
       org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
dk.releaze.servlet.http.RealtimeHttpServlet.gotoPage(Unknown Source) dk.releaze.service.web.smsbulk.servlets.Index.doGetRequest(Index.java:75) dk.releaze.servlet.http.RealtimeHttpServlet.doGet(Unknown Source)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
dk.releaze.servlet.http.RealtimeHttpServlet.service(Unknown Source)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

If I change the useBean declaration into

   ...
   <jsp:useBean id="loginFailed" class="java.lang.String"
   scope="request" />
   ...

it works fine - no errors.
Now, I find this to be weird.
Why can't Tomcat find the String class without qualifying the path? (I think thats the problem) It's an impossible task to rewrite all our JSP files into using fully qualified path names, I hope that this is just a configuration issue that I have missed.
My hope is that someone can explain this error to me.

Thanks,
Frederik Gottlieb
Releaze Aps.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to