You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Filip Hanik - Dev Lists <de...@hanik.com> on 2006/12/05 20:22:12 UTC
Beans without packages in JSP files
Are we intentionally not supporting this?
Would it be possible to set a flag to allow this?
I could expand the patch, that if the packageName parameter in
findType(char[] typeName, char[][] packageName)
starts with "org.apache.jsp" then it would do the same as below, try to
resolve it as a single class
any thoughts, any more correct solution?
Filip
Index: java/org/apache/jasper/compiler/JDTCompiler.java
===================================================================
--- java/org/apache/jasper/compiler/JDTCompiler.java (revision 482723)
+++ java/org/apache/jasper/compiler/JDTCompiler.java (working copy)
@@ -167,7 +167,13 @@
}
result += sep;
result += new String(typeName);
- return findType(result);
+ NameEnvironmentAnswer ne = findType(result);
+ if ( ne == null /* && check empty package */ ) {
+ result = new String(typeName);
+ ne = findType(result);
+
+ }
+ return ne;
}
private NameEnvironmentAnswer findType(String className) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: Beans without packages in JSP files
Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
just because I can't shut up, but everyone should know that by now,
If I wanted this JSP to work
<%=A.test()%>
then I would simply do this
1. place A.class in WEB-INF/classes/ (required for running the compiled
JSP, runtime class loading)
2. place A.class in WEB-INF/classes/org/apache/jsp/ (required for the
compilation to work, compile time class loading)
so there is a way to run it, what I was trying to do, was simply
eliminate step 1.
Filip
Filip Hanik - Dev Lists wrote:
> Yoav Shapira wrote:
>> Hi,
>>
>> On 12/5/06, Filip Hanik - Dev Lists <de...@hanik.com> wrote:
>>> I'm not talking about
>>> import A;
>>>
>>> I'm talking about simply using A in the JSP
>>>
>>> <%=A.test()%> without using an import,
>>>
>>> This doesn't work, cause our JSP page gets packaged as
>>> org.apache.jsp.<directory> and our code adds that before it tries to
>>> resolve A
>>
>> I apologize, I guess I wasn't clear ;)
>>
>> First of all, this is not new stuff at all. It's been in our FAQ
>> (http://tomcat.apache.org/faq/classnotfound.html) for at least a
>> couple of years. What made you bring it up now?
> Just ran into an issue where this was the case, made me look into the
> code to see how A got resolved,
> basically, it tries to load org.apache.jsp.<directory>.A.
> if A was not identified by a import statement and sits in a package.
> This is an app that runs om Tomcat 3, where it is working just dandy :)
>
> I hadn't realized that it had changed on the javac level to not work
> on this, thanks for pointing it out.
>>
>> In your example, what does "simply using A in the JSP" mean? What
>> does it look like in the compiled servlet that the JSP is turned into?
>> You have to resolve it to *some* package. Are you saying the current
>> code assigns a default org.apache.jsp package *before* doing this
>> resolving? I doubt that's the case, or everyone's beans that are not
>> in org.apache.jsp would break...
> Nope, just if it doesn't belong in a package already. Then it will
> guess that the prefix should be the package that the JSP is in.
>
> I'm over it, scratch everything I said, this conversation never happened.
> Filip
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: Beans without packages in JSP files
Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
Yoav Shapira wrote:
> Hi,
>
> On 12/5/06, Filip Hanik - Dev Lists <de...@hanik.com> wrote:
>> I'm not talking about
>> import A;
>>
>> I'm talking about simply using A in the JSP
>>
>> <%=A.test()%> without using an import,
>>
>> This doesn't work, cause our JSP page gets packaged as
>> org.apache.jsp.<directory> and our code adds that before it tries to
>> resolve A
>
> I apologize, I guess I wasn't clear ;)
>
> First of all, this is not new stuff at all. It's been in our FAQ
> (http://tomcat.apache.org/faq/classnotfound.html) for at least a
> couple of years. What made you bring it up now?
Just ran into an issue where this was the case, made me look into the
code to see how A got resolved,
basically, it tries to load org.apache.jsp.<directory>.A.
if A was not identified by a import statement and sits in a package.
This is an app that runs om Tomcat 3, where it is working just dandy :)
I hadn't realized that it had changed on the javac level to not work on
this, thanks for pointing it out.
>
> In your example, what does "simply using A in the JSP" mean? What
> does it look like in the compiled servlet that the JSP is turned into?
> You have to resolve it to *some* package. Are you saying the current
> code assigns a default org.apache.jsp package *before* doing this
> resolving? I doubt that's the case, or everyone's beans that are not
> in org.apache.jsp would break...
Nope, just if it doesn't belong in a package already. Then it will guess
that the prefix should be the package that the JSP is in.
I'm over it, scratch everything I said, this conversation never happened.
Filip
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: Beans without packages in JSP files
Posted by Yoav Shapira <yo...@apache.org>.
Hi,
On 12/5/06, Filip Hanik - Dev Lists <de...@hanik.com> wrote:
> I'm not talking about
> import A;
>
> I'm talking about simply using A in the JSP
>
> <%=A.test()%> without using an import,
>
> This doesn't work, cause our JSP page gets packaged as
> org.apache.jsp.<directory> and our code adds that before it tries to
> resolve A
I apologize, I guess I wasn't clear ;)
First of all, this is not new stuff at all. It's been in our FAQ
(http://tomcat.apache.org/faq/classnotfound.html) for at least a
couple of years. What made you bring it up now?
In your example, what does "simply using A in the JSP" mean? What
does it look like in the compiled servlet that the JSP is turned into?
You have to resolve it to *some* package. Are you saying the current
code assigns a default org.apache.jsp package *before* doing this
resolving? I doubt that's the case, or everyone's beans that are not
in org.apache.jsp would break...
Yoav
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: Beans without packages in JSP files
Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
I'm not talking about
import A;
I'm talking about simply using A in the JSP
<%=A.test()%> without using an import,
This doesn't work, cause our JSP page gets packaged as
org.apache.jsp.<directory> and our code adds that before it tries to
resolve A
Filip
Yoav Shapira wrote:
> Hi,
> I think we are intentionally not supporting this, because Java itself
> (as of 1.4 IIRC) doesn't support it. See for example
> http://forum.java.sun.com/thread.jspa?threadID=733449&messageID=4217703
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4361575
> http://forum.java.sun.com/thread.jspa?threadID=789673
>
> Yoav
>
>
> On 12/5/06, Filip Hanik - Dev Lists <de...@hanik.com> wrote:
>> Are we intentionally not supporting this?
>> Would it be possible to set a flag to allow this?
>>
>> I could expand the patch, that if the packageName parameter in
>> findType(char[] typeName, char[][] packageName)
>> starts with "org.apache.jsp" then it would do the same as below, try to
>> resolve it as a single class
>>
>> any thoughts, any more correct solution?
>> Filip
>>
>>
>> Index: java/org/apache/jasper/compiler/JDTCompiler.java
>> ===================================================================
>> --- java/org/apache/jasper/compiler/JDTCompiler.java (revision
>> 482723)
>> +++ java/org/apache/jasper/compiler/JDTCompiler.java (working copy)
>> @@ -167,7 +167,13 @@
>> }
>> result += sep;
>> result += new String(typeName);
>> - return findType(result);
>> + NameEnvironmentAnswer ne = findType(result);
>> + if ( ne == null /* && check empty package */
>> ) {
>> + result = new String(typeName);
>> + ne = findType(result);
>> +
>> + }
>> + return ne;
>> }
>>
>> private NameEnvironmentAnswer findType(String
>> className) {
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: Beans without packages in JSP files
Posted by Yoav Shapira <yo...@apache.org>.
Hi,
I think we are intentionally not supporting this, because Java itself
(as of 1.4 IIRC) doesn't support it. See for example
http://forum.java.sun.com/thread.jspa?threadID=733449&messageID=4217703
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4361575
http://forum.java.sun.com/thread.jspa?threadID=789673
Yoav
On 12/5/06, Filip Hanik - Dev Lists <de...@hanik.com> wrote:
> Are we intentionally not supporting this?
> Would it be possible to set a flag to allow this?
>
> I could expand the patch, that if the packageName parameter in
> findType(char[] typeName, char[][] packageName)
> starts with "org.apache.jsp" then it would do the same as below, try to
> resolve it as a single class
>
> any thoughts, any more correct solution?
> Filip
>
>
> Index: java/org/apache/jasper/compiler/JDTCompiler.java
> ===================================================================
> --- java/org/apache/jasper/compiler/JDTCompiler.java (revision 482723)
> +++ java/org/apache/jasper/compiler/JDTCompiler.java (working copy)
> @@ -167,7 +167,13 @@
> }
> result += sep;
> result += new String(typeName);
> - return findType(result);
> + NameEnvironmentAnswer ne = findType(result);
> + if ( ne == null /* && check empty package */ ) {
> + result = new String(typeName);
> + ne = findType(result);
> +
> + }
> + return ne;
> }
>
> private NameEnvironmentAnswer findType(String className) {
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org