tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Georg Sauer-Limbach <g...@gslweb.de>
Subject Re: Accessing a class file under WEB-INF/classes from JSP
Date Wed, 23 May 2007 19:27:54 GMT
Hi,

it is in the Java Server Pages 2.0 Specification:
(http://jcp.org/aboutJava/communityprocess/final/jsr152/)

"As of JSP 2.0, it is illegal to refer to any classes from the unnamed (a.k.a.
default) package. This may result in a translation error on some containers,
specifically those that run in a JDK 1.4 or greater environment. It is unfortunate,
but unavoidable, that this will break compatibility with some older JSP
applications."

Tomcat 5 implements JSP 2.0, Tomcat 4 did implement JSP 1.x, so it
is correct that this feature vanished from Tomcat 4 to 5.

Georg


David Smith wrote:
> You have to package the classes and then refer to them by their fully 
> qualified name -- ie javax.servlet.http.HttpServletRequest.  This change 
> was made a long time ago (tomcat 4.x?).
> 
> The classes themselves have to be in either a jar file in WEB-INF/lib or 
> in a folder structure mirroring the package in WEB-INF/classes.  
> HttpServletRequest.class of the package javax.servlet.http for example 
> would be in WEB-INF/classes/javax/servlet/http
> 
> I know in some corner conditions packageless classes have been allowed 
> (ie servlet class names), but it's really a much better practice to get 
> them into declared packages.
> 
> --David
> 
> Rajiv M wrote:
> 
>> No. This will again give class cannot be resolved to type error
>>
>> On 5/23/07, Robert Soeding <robert.soeding@gmx.net> wrote:
>>
>>> Does
>>> <%@page import="YourClass"%>
>>> work?
>>>
>>> Rajiv M wrote:
>>> > Seems like with JDK 1.4, Sun has enforced classes belonging to the
>>> > default package from being imported in JSP. Is the only way to resolve
>>> > the problem is to include classes under a package and then import the
>>> > package in JSP?
>>> >
>>> > Or is there some way in Tomcat which can cause JSP to access the class
>>> > files from WEB-INF/classes directory
>>> >
>>> > ---------------------------------------------------------------------
>>> > To start a new topic, e-mail: users@tomcat.apache.org
>>> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> > For additional commands, e-mail: users-help@tomcat.apache.org
>>> >
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 

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


Mime
View raw message