You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Charles So <ch...@mac.com> on 2003/01/18 13:50:21 UTC

Strange error when importing class in JSP under TC4.1.18

Dear all,

I am tearing my hair out trying to solve this problem... it seems to be  
a problem with TC.

Here is the exception from TC:

org.apache.jasper.JasperException
	at  
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.ja 
va:248)
	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.ApplicationDispatcher.invoke(ApplicationDispatc 
her.java:684)
	at  
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDisp 
atcher.java:432)
	at  
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispat 
cher.java:356)
	at WelcomeServlet.gotoPage(WelcomeServlet.java:197)
	at WelcomeServlet.doGet(WelcomeServlet.java:125)

The servlet, WelcomeServlet, finishes putting a array of object of type  
MajorCat, and NewItem into session.

	...
         session.setAttribute("majorcat", majorcat);
         session.setAttribute("newitem", newitem);

         gotoPage("/Welcome.jsp", request, response);
	...

Then go straight to the Welcome.jsp page.


The page uses the majorcat object.

Here is the beginning of the JSP file:

<%@page import="MajorCat" %>
<jsp:useBean id="majorcat" class="MajorCat[]" scope="session" />
<html>
...


TC 4.1.18 doesn't like it. It just throws the above mentioned exception.

I take the two lines out, and take out all JSP code which uses  
majorcat, then it works fine!


Strangely, it worked fine before!


What's the problem??? Please shed some light and share your thought!

Many, many thanks!

charles

Re: Strange error when importing class in JSP under TC4.1.18

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Sat, 18 Jan 2003, Charles So wrote:

> Date: Sat, 18 Jan 2003 20:50:21 +0800
> From: Charles So <ch...@mac.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: tomcat-user@jakarta.apache.org
> Subject: Strange error when importing class in JSP under TC4.1.18
>
> Dear all,
>
> I am tearing my hair out trying to solve this problem... it seems to be
> a problem with TC.
>

If you're running JDK 1.4.1 or later, it's not Tomcat -- it's the JDK that
doesn't like this.

JDK 1.4.1 tightened up rules that have always been in the Java Language
Specification (but never enforced by javac) that you can't import an
unpackaged class.  That's exactly what you are trying to do here.

Place your classes in packages and they'll work fine.

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>