Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2005-07-21 Thread Jan Luehe
Bill,

[EMAIL PROTECTED] wrote:
 billbarker2005/07/20 20:59:10
 
   Modified:jasper2/src/share/org/apache/jasper/compiler Generator.java
   Log:
   Make certain that release is called for custom tags when tag-pooling is 
 disabled.
   
   Fix for Bug #35696
   
   Revision  ChangesPath
   1.241 +9 -2  
 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java
   
   Index: Generator.java
   ===
   RCS file: 
 /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
   retrieving revision 1.240
   retrieving revision 1.241
   diff -u -r1.240 -r1.241
   --- Generator.java  5 Apr 2005 23:14:43 -   1.240
   +++ Generator.java  21 Jul 2005 03:59:10 -  1.241
   @@ -2278,15 +2278,19 @@
out.printin(if ();
out.print(tagHandlerVar);
out.println(
   -.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE));
   +.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) 
 {);
out.pushIndent();
   +if(!n.implementsTryCatchFinally()) {
   +out.printin(tagHandlerVar);
   +out.println(.release(););
   +}

I believe the above 4 added lines need to be replaced with this:

+if (!n.implementsTryCatchFinally()) {
+
+if (isPoolingEnabled) {
+out.printin(n.getTagHandlerPoolName());
+out.print(.reuse();
+out.print(tagHandlerVar);
+out.println(););
+} else {
+out.printin(tagHandlerVar);
+out.println(.release(););
+}
+}


Jan


if (isTagFile || isFragment) {
out.printil(throw new SkipPageException(););
} else {
out.printil((methodNesting  0) ? return true; : 
 return;);
}
out.popIndent();
   -
   +out.printil(});
// Synchronize AT_BEGIN scripting variables
syncScriptingVars(n, VariableInfo.AT_BEGIN);

   @@ -2317,6 +2321,9 @@
out.print(.reuse();
out.print(tagHandlerVar);
out.println(););
   +} else {
   +out.printin(tagHandlerVar);
   +out.println(.release(););
}

if (n.implementsTryCatchFinally()) {
   
   
   
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2005-07-21 Thread Bill Barker


- Original Message - 
From: Jan Luehe [EMAIL PROTECTED]

To: Tomcat Developers List tomcat-dev@jakarta.apache.org
Sent: Thursday, July 21, 2005 6:24 PM
Subject: Re: cvs commit: 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler 
Generator.java




Bill,

[EMAIL PROTECTED] wrote:

billbarker2005/07/20 20:59:10

  Modified:jasper2/src/share/org/apache/jasper/compiler 
Generator.java

  Log:
  Make certain that release is called for custom tags when tag-pooling is 
disabled.


  Fix for Bug #35696

  Revision  ChangesPath
  1.241 +9 -2 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java


  Index: Generator.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v

  retrieving revision 1.240
  retrieving revision 1.241
  diff -u -r1.240 -r1.241
  --- Generator.java 5 Apr 2005 23:14:43 - 1.240
  +++ Generator.java 21 Jul 2005 03:59:10 - 1.241
  @@ -2278,15 +2278,19 @@
   out.printin(if ();
   out.print(tagHandlerVar);
   out.println(
  -.doEndTag() == 
javax.servlet.jsp.tagext.Tag.SKIP_PAGE));
  +.doEndTag() == 
javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {);

   out.pushIndent();
  +if(!n.implementsTryCatchFinally()) {
  +out.printin(tagHandlerVar);
  +out.println(.release(););
  +}


I believe the above 4 added lines need to be replaced with this:



Yeah, but but the previous code was simply throwing the tag away on 
SKIP_PAGE (at least for non-TCF tags), and I didn't want to dig to find out 
if it was doing it for a reason (especially since SKIP_PAGE happens almost 
never :).  I figured that if we're going to throw it away, we should at 
least call release on it first :).



   +if (!n.implementsTryCatchFinally()) {
   +
   +if (isPoolingEnabled) {
   +out.printin(n.getTagHandlerPoolName());
   +out.print(.reuse();
   +out.print(tagHandlerVar);
   +out.println(););
   +} else {
   +out.printin(tagHandlerVar);
   +out.println(.release(););
   +}
   +}


Jan



   if (isTagFile || isFragment) {
   out.printil(throw new SkipPageException(););
   } else {
   out.printil((methodNesting  0) ? return true; : 
return;);

   }
   out.popIndent();
  -
  +out.printil(});
   // Synchronize AT_BEGIN scripting variables
   syncScriptingVars(n, VariableInfo.AT_BEGIN);

  @@ -2317,6 +2321,9 @@
   out.print(.reuse();
   out.print(tagHandlerVar);
   out.println(););
  +} else {
  +out.printin(tagHandlerVar);
  +out.println(.release(););
   }

   if (n.implementsTryCatchFinally()) {




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







This message is intended only for the use of the person(s) listed above as the 
intended recipient(s), and may contain information that is PRIVILEGED and 
CONFIDENTIAL.  If you are not an intended recipient, you may not read, copy, or 
distribute this message or any attachment. If you received this communication 
in error, please notify us immediately by e-mail and then delete all copies of 
this message and any attachments.

In addition you should be aware that ordinary (unencrypted) e-mail sent through 
the Internet is not secure. Do not send confidential or sensitive information, 
such as social security numbers, account numbers, personal identification 
numbers and passwords, to us via ordinary (unencrypted) e-mail.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2004-02-03 Thread Remy Maucherat
Mark Roth wrote:
Okay, I took a look at the patch and the bug report and I think I know 
what's going on now.  Please let me know if I do not understand the 
scenario correctly.

It seems there are some JSP 1.2 pages that misuse jsp:useBean by doing 
one of the following:

  1. The class attribute is used for a Java type that cannot
 be instantiated as a JavaBean.
  2. Type or class specifies a type that cannot be found.
There are some cases where pages can get away with (1) if the container 
decides to flag this as a runtime error.  These pages are invalid but 
the container never calls them on it because the objects already exist 
in some scope.  This is probably less likely with (2), but still 
possible (e.g. if the jsp:useBean never gets executed at all).

It would be nice to get a translation error in this case so that you 
realize your page is invalid.  However, the JSP 1.2 specification (on 
which Tomcat 4.x is based) does not allow for a translation error - it 
requires that a runtime exception must be thrown.

In JSP 2.0 (on which Tomcat 5.x is based), a number of JSP container 
vendors complained about this and wanted the freedom to throw a 
translation error in this case.  Doing so is better for the page author 
(since they know up front their page is invalid) and better for the 
container (since doing a 'new' is MUCH more efficient than doing a call 
to Beans.instantiate()).  So, we added a provision to allow containers 
to optionally produce a translation error on these invalid pages.

One unfortunate side-effect is that some pages that used to compile in 
Tomcat 4 will no longer compile in Tomcat 5.  But it's important to 
realize that these pages are invalid in both specs.  It's just that 
Tomcat 4 was not allowed to cause an error at translation time.  It had 
to wait until runtime to do so.

So where does this leave us with respect to this patch?  Tomcat 5 is 
free to exhibit either behavior.  It can throw a translation error or a 
runtime error for these invalid pages.  In my opinion, it is much better 
for both the page author and the container if we produce a 
translation-time error.  The page author knows their page is invalid 
right away (without having to exercise the code path), and the container 
can gain the performance benefits associated with doing a 'new' call 
directly (instead of Beans.instantiate()).

So it's your call, but if I had a vote I'd say stick with Kin-Man's patch.

Hope this helps.
Thanks for the explanations :)

Rémy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2004-02-02 Thread Kin-Man Chung
-1.

Remy, please reread JSP 2.0 spec, p 1-101,1-102.  Bullet .2 of the Semantics
section was added to allow for this kind of optimization.  Bullet .5 and .6
will be executed ONLY IF the container choose not to issue translation errors.

-Kin-man

 Date: Mon, 02 Feb 2004 18:18:01 +
 From: [EMAIL PROTECTED]
 Subject: cvs commit: 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler 
Generator.java
 To: [EMAIL PROTECTED]
 
 remm2004/02/02 10:18:01
 
   Modified:jasper2/src/share/org/apache/jasper/compiler Generator.java
   Log:
   - Revert useBean optimization done by Kin-Man, as it seems to violate the
 spec wording (which basically says that an error should occur at runtime 
if the class
 is not a JavaBean).
   - Bug 26507.
   
   Revision  ChangesPath
   1.217 +31 -35
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.jav
a
   
   Index: Generator.java
   ===
   RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Gen
erator.java,v
   retrieving revision 1.216
   retrieving revision 1.217
   diff -u -r1.216 -r1.217
   --- Generator.java  31 Jan 2004 01:56:28 -  1.216
   +++ Generator.java  2 Feb 2004 18:18:00 -   1.217
   @@ -1261,41 +1261,37 @@
className =
attributeValue(beanName, false, String.class);
}
   -out.printil(try {);
   -out.pushIndent();
   -out.printin(name);
   -out.print( = ();
   -out.print(type);
   -out.print() java.beans.Beans.instantiate();
   -out.print(this.getClass().getClassLoader(), );
   -out.print(className);
   -out.println(););
   -out.popIndent();
   -/*
   - * Note: Beans.instantiate throws 
ClassNotFoundException
   - * if the bean class is abstract.
   - */
   -out.printil(} catch (ClassNotFoundException exc) {);
   -out.pushIndent();
   -out.printil(
   -throw new 
InstantiationException(exc.getMessage()););
   -out.popIndent();
   -out.printil(} catch (Exception exc) {);
   -out.pushIndent();
   -out.printin(throw new ServletException();
   -out.print(\Cannot create bean of class \ + );
   -out.print(className);
   -out.println(, exc););
   -out.popIndent();
   -out.printil(}); // close of try
} else {
// Implies klass is not null
   -// Generate codes to instantiate the bean class
   -out.printin(name);
   -out.print( = new );
   -out.print(klass);
   -out.println((););
   +className = quote(klass);
}
   +out.printil(try {);
   +out.pushIndent();
   +out.printin(name);
   +out.print( = ();
   +out.print(type);
   +out.print() java.beans.Beans.instantiate();
   +out.print(this.getClass().getClassLoader(), );
   +out.print(className);
   +out.println(););
   +out.popIndent();
   +/*
   + * Note: Beans.instantiate throws ClassNotFoundException
   + * if the bean class is abstract.
   + */
   +out.printil(} catch (ClassNotFoundException exc) {);
   +out.pushIndent();
   +out.printil(
   +throw new InstantiationException(exc.getMessage()););
   +out.popIndent();
   +out.printil(} catch (Exception exc) {);
   +out.pushIndent();
   +out.printin(throw new ServletException();
   +out.print(\Cannot create bean of class \ + );
   +out.print(className);
   +out.println(, exc););
   +out.popIndent();
   +out.printil(}); // close of try
/*
 * Set attribute for bean in the specified scope
 */
   
   
   
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, 

Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2004-02-02 Thread Remy Maucherat
Kin-Man Chung wrote:
-1.

Remy, please reread JSP 2.0 spec, p 1-101,1-102.  Bullet .2 of the Semantics
section was added to allow for this kind of optimization.  Bullet .5 and .6
will be executed ONLY IF the container choose not to issue translation errors.
I cannot really understand what the fragment really means, so I don't 
know. I had the impression that it implied that the error should be at 
runtime.
I recommend the change is reverted as I did, as many users will likely 
make the same mistake, since the specification is impossible to 
understand (if you are right and your change indeed does not break the 
specification). This will also create compilation errors when upgrading 
from TC 4 to TC 5.

Rémy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2004-02-02 Thread Kin-Man Chung
Agreed that the spec can be clearer.  :-)

This has been discussed by the Spec expert group, and bullet .2 was added
because some vendors wanted it.  I'll check with the spec lead for a
clarification.

Also agreed that this breaks backward compatibility; but it not really too
bad.  I think a lot of users would rather have the error at compilation
time than at runtime.  What can you do with an instantiation error at
runtime?

If we are really concern about BC, then we can add another compilation
option to revert to old behavior.  I really don't like another switch, but
if it'll make people happy...

-Kin-man

 Date: Mon, 02 Feb 2004 19:41:54 +0100
 From: Remy Maucherat [EMAIL PROTECTED]
 Subject: Re: cvs commit: 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler 
Generator.java
 To: Tomcat Developers List [EMAIL PROTECTED]
 
 Kin-Man Chung wrote:
  -1.
  
  Remy, please reread JSP 2.0 spec, p 1-101,1-102.  Bullet .2 of the Semantics
  section was added to allow for this kind of optimization.  Bullet .5 and .6
  will be executed ONLY IF the container choose not to issue translation 
errors.
 
 I cannot really understand what the fragment really means, so I don't 
 know. I had the impression that it implied that the error should be at 
 runtime.
 I recommend the change is reverted as I did, as many users will likely 
 make the same mistake, since the specification is impossible to 
 understand (if you are right and your change indeed does not break the 
 specification). This will also create compilation errors when upgrading 
 from TC 4 to TC 5.
 
 Rémy
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2004-02-02 Thread Remy Maucherat
Kin-Man Chung wrote:
Agreed that the spec can be clearer.  :-)

This has been discussed by the Spec expert group, and bullet .2 was added
because some vendors wanted it.  I'll check with the spec lead for a
clarification.
Ok.

Also agreed that this breaks backward compatibility; but it not really too
bad.  I think a lot of users would rather have the error at compilation
time than at runtime.  What can you do with an instantiation error at
runtime?
Nothing, but some don't care: they never intended their page to be 
called without the right attribute in the right scope, so the case where 
their JavaBean is instantiated never happens.

If we are really concern about BC, then we can add another compilation
option to revert to old behavior.  I really don't like another switch, but
if it'll make people happy...
No new switch, please ;) So we have to decide one or the other.
So do you want me to revert the patch ?
Rémy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2004-02-02 Thread Kin-Man Chung

 Date: Mon, 02 Feb 2004 20:17:29 +0100
 From: Remy Maucherat [EMAIL PROTECTED]
 Subject: Re: cvs commit: 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler 
Generator.java
 To: Tomcat Developers List [EMAIL PROTECTED]
 
 Kin-Man Chung wrote:
  Agreed that the spec can be clearer.  :-)
  
  This has been discussed by the Spec expert group, and bullet .2 was added
  because some vendors wanted it.  I'll check with the spec lead for a
  clarification.
 
 Ok.
 
  Also agreed that this breaks backward compatibility; but it not really too
  bad.  I think a lot of users would rather have the error at compilation
  time than at runtime.  What can you do with an instantiation error at
  runtime?
 
 Nothing, but some don't care: they never intended their page to be 
 called without the right attribute in the right scope, so the case where 
 their JavaBean is instantiated never happens.

Then EL should be used in this case.

 
  If we are really concern about BC, then we can add another compilation
  option to revert to old behavior.  I really don't like another switch, but
  if it'll make people happy...
 
 No new switch, please ;) So we have to decide one or the other.
 So do you want me to revert the patch ?
 

I'd rather you check with me first before the patch, but since it is
already done, let's wait for the spec clarification before we do anything.
A revert on a revert would make us look really silly.  :-)

-Kin-man

 Rémy
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2004-02-02 Thread Remy Maucherat
Kin-Man Chung wrote:
I'd rather you check with me first before the patch, but since it is
already done, let's wait for the spec clarification before we do anything.
A revert on a revert would make us look really silly.  :-)
This has been lying in BZ for a while, that's why I just patched.
Ok, I'll wait to revert it.
Rémy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2004-02-02 Thread Mark Roth
Hi Kin-Man,

I'm just about to look into this.  I'll try to have an answer for you by 
tonight.

- Mark

Kin-Man Chung wrote:
-1.

Remy, please reread JSP 2.0 spec, p 1-101,1-102.  Bullet .2 of the Semantics
section was added to allow for this kind of optimization.  Bullet .5 and .6
will be executed ONLY IF the container choose not to issue translation errors.
-Kin-man


Date: Mon, 02 Feb 2004 18:18:01 +
From: [EMAIL PROTECTED]
Subject: cvs commit: 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler 
Generator.java

To: [EMAIL PROTECTED]

remm2004/02/02 10:18:01

 Modified:jasper2/src/share/org/apache/jasper/compiler Generator.java
 Log:
 - Revert useBean optimization done by Kin-Man, as it seems to violate the
   spec wording (which basically says that an error should occur at runtime 
if the class

   is not a JavaBean).
 - Bug 26507.
 
 Revision  ChangesPath
 1.217 +31 -35
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.jav
a
 
 Index: Generator.java
 ===
 RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Gen
erator.java,v
 retrieving revision 1.216
 retrieving revision 1.217
 diff -u -r1.216 -r1.217
 --- Generator.java	31 Jan 2004 01:56:28 -	1.216
 +++ Generator.java	2 Feb 2004 18:18:00 -	1.217
 @@ -1261,41 +1261,37 @@
  className =
  attributeValue(beanName, false, String.class);
  }
 -out.printil(try {);
 -out.pushIndent();
 -out.printin(name);
 -out.print( = ();
 -out.print(type);
 -out.print() java.beans.Beans.instantiate();
 -out.print(this.getClass().getClassLoader(), );
 -out.print(className);
 -out.println(););
 -out.popIndent();
 -/*
 - * Note: Beans.instantiate throws 
ClassNotFoundException

 - * if the bean class is abstract.
 - */
 -out.printil(} catch (ClassNotFoundException exc) {);
 -out.pushIndent();
 -out.printil(
 -throw new 
InstantiationException(exc.getMessage()););

 -out.popIndent();
 -out.printil(} catch (Exception exc) {);
 -out.pushIndent();
 -out.printin(throw new ServletException();
 -out.print(\Cannot create bean of class \ + );
 -out.print(className);
 -out.println(, exc););
 -out.popIndent();
 -out.printil(}); // close of try
  } else {
  // Implies klass is not null
 -// Generate codes to instantiate the bean class
 -out.printin(name);
 -out.print( = new );
 -out.print(klass);
 -out.println((););
 +className = quote(klass);
  }
 +out.printil(try {);
 +out.pushIndent();
 +out.printin(name);
 +out.print( = ();
 +out.print(type);
 +out.print() java.beans.Beans.instantiate();
 +out.print(this.getClass().getClassLoader(), );
 +out.print(className);
 +out.println(););
 +out.popIndent();
 +/*
 + * Note: Beans.instantiate throws ClassNotFoundException
 + * if the bean class is abstract.
 + */
 +out.printil(} catch (ClassNotFoundException exc) {);
 +out.pushIndent();
 +out.printil(
 +throw new InstantiationException(exc.getMessage()););
 +out.popIndent();
 +out.printil(} catch (Exception exc) {);
 +out.pushIndent();
 +out.printin(throw new ServletException();
 +out.print(\Cannot create bean of class \ + );
 +out.print(className);
 +out.println(, exc););
 +out.popIndent();
 +out.printil(}); // close of try
  /*
   * Set attribute for bean in the specified scope
   */
 
 
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2004-02-02 Thread Mark Roth
Okay, I took a look at the patch and the bug report and I think I know 
what's going on now.  Please let me know if I do not understand the 
scenario correctly.

It seems there are some JSP 1.2 pages that misuse jsp:useBean by doing 
one of the following:

  1. The class attribute is used for a Java type that cannot
 be instantiated as a JavaBean.
  2. Type or class specifies a type that cannot be found.
There are some cases where pages can get away with (1) if the container 
decides to flag this as a runtime error.  These pages are invalid but 
the container never calls them on it because the objects already exist 
in some scope.  This is probably less likely with (2), but still 
possible (e.g. if the jsp:useBean never gets executed at all).

It would be nice to get a translation error in this case so that you 
realize your page is invalid.  However, the JSP 1.2 specification (on 
which Tomcat 4.x is based) does not allow for a translation error - it 
requires that a runtime exception must be thrown.

In JSP 2.0 (on which Tomcat 5.x is based), a number of JSP container 
vendors complained about this and wanted the freedom to throw a 
translation error in this case.  Doing so is better for the page author 
(since they know up front their page is invalid) and better for the 
container (since doing a 'new' is MUCH more efficient than doing a call 
to Beans.instantiate()).  So, we added a provision to allow containers 
to optionally produce a translation error on these invalid pages.

One unfortunate side-effect is that some pages that used to compile in 
Tomcat 4 will no longer compile in Tomcat 5.  But it's important to 
realize that these pages are invalid in both specs.  It's just that 
Tomcat 4 was not allowed to cause an error at translation time.  It had 
to wait until runtime to do so.

So where does this leave us with respect to this patch?  Tomcat 5 is 
free to exhibit either behavior.  It can throw a translation error or a 
runtime error for these invalid pages.  In my opinion, it is much better 
for both the page author and the container if we produce a 
translation-time error.  The page author knows their page is invalid 
right away (without having to exercise the code path), and the container 
can gain the performance benefits associated with doing a 'new' call 
directly (instead of Beans.instantiate()).

So it's your call, but if I had a vote I'd say stick with Kin-Man's patch.

Hope this helps.

---
Mark Roth, Java Software
JSP 2.0 Co-Specification Lead
Sun Microsystems, Inc.


Remy Maucherat wrote:
Kin-Man Chung wrote:

Agreed that the spec can be clearer.  :-)

This has been discussed by the Spec expert group, and bullet .2 was added
because some vendors wanted it.  I'll check with the spec lead for a
clarification.


Ok.

Also agreed that this breaks backward compatibility; but it not really 
too
bad.  I think a lot of users would rather have the error at compilation
time than at runtime.  What can you do with an instantiation error at
runtime?


Nothing, but some don't care: they never intended their page to be 
called without the right attribute in the right scope, so the case where 
their JavaBean is instantiated never happens.

If we are really concern about BC, then we can add another compilation
option to revert to old behavior.  I really don't like another switch, 
but
if it'll make people happy...


No new switch, please ;) So we have to decide one or the other.
So do you want me to revert the patch ?
Rémy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2003-09-22 Thread Kin-Man Chung
Eric,

I forgot about those generated Declartions.  It good to have an extra
pair of eyes to keep one honest.  Thanks.  :)

I have committed a fix for this and the last you reported.  Please see if
it works better now.  I have noticed that smap now contains lots of
overlaps, because of duplications in the unoptimized smap.  I'll leave
to you as an exercise to remove them in smap optimizations  :-)  Enough
smap for me for the time being.

-Kin-man

 Date: Sat, 20 Sep 2003 00:45:21 -0700
 From: Eric Carmichael [EMAIL PROTECTED]
 Subject: Re: cvs commit: 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler 
Generator.java
 X-Originating-IP: [64.203.49.21]
 To: Tomcat Developers List [EMAIL PROTECTED]
 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
 X-Priority: 3
 X-MSMail-priority: Normal
 X-Originating-Email: [EMAIL PROTECTED]
 X-OriginalArrivalTime: 20 Sep 2003 07:45:25.0789 (UTC) 
FILETIME=[2776FCD0:01C37F4B]
 
 This SMAPs all declaration nodes, including the ones tacked on to the root 
node by ELFunctionMapper.java.  So for instance the SMAP for 
jsp2/el/functions.jsp from the jsp-examples webapp ends with
 
 43,6:120
 1,3:10
 1,5:13
 
 thus SMAPping 
 
   %@ taglib prefix=my 
uri=http://jakarta.apache.org/tomcat/jsp2-example-taglib%
 
 to
 
   static private org.apache.jasper.runtime.ProtectedFunctionMapper 
_jspx_fnmap_0;
   static private org.apache.jasper.runtime.ProtectedFunctionMapper 
_jspx_fnmap_1;
 
 and
 
   static {
 _jspx_fnmap_0= 
org.apache.jasper.runtime.ProtectedFunctionMapper.getMapForFunction(my:reverse
, jsp2.examples.el.Functions.class, reverse, new Class[] 
{java.lang.String.class});
 _jspx_fnmap_1= 
org.apache.jasper.runtime.ProtectedFunctionMapper.getMapForFunction(my:countVow
els, jsp2.examples.el.Functions.class, numVowels, new Class[] 
{java.lang.String.class});
   }
 
 which is clearly wrong.
 
 Eric
 
 - Original Message - 
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, September 19, 2003 4:38 PM
 Subject: cvs commit: 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler 
Generator.java
 
 
  kinman  2003/09/19 16:38:09
  
Modified:jasper2/src/share/org/apache/jasper/compiler Generator.java
Log:
- Make sure scriptlet declarations get properly mapped.  This fixes 22833

Revision  ChangesPath
1.211 +7 -6  
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.jav
a

Index: Generator.java
===
RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Gen
erator.java,v
retrieving revision 1.210
retrieving revision 1.211
diff -u -r1.210 -r1.211
--- Generator.java 19 Sep 2003 18:30:09 - 1.210
+++ Generator.java 19 Sep 2003 23:38:08 - 1.211
@@ -196,9 +196,7 @@
  */
 public void visit(Node.PageDirective n) throws 
JasperException {
 
-if (!getServletInfoGenerated) {
-getServletInfoGenerated = true;
-} else {
+if (getServletInfoGenerated) {
 return;
 }
 
@@ -206,6 +204,7 @@
 if (info == null)
 return;
 
+getServletInfoGenerated = true;
 out.printil(public String getServletInfo() {);
 out.pushIndent();
 out.printin(return );
@@ -217,8 +216,10 @@
 }
 
 public void visit(Node.Declaration n) throws JasperException 
{
+n.setBeginJavaLine(out.getJavaLine());
 out.printMultiLn(new String(n.getText()));
 out.println();
+n.setEndJavaLine(out.getJavaLine());
 }
 
 // Custom Tags may contain declarations from tag plugins.



  
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
  


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java Node.java SmapStratum.java SmapUtil.java

2003-09-22 Thread Eric Carmichael
 But really, all this is more academic than useful in practice: who do
 you think may need to single step over template text lines?  :-)

No idea.  I'm just trying to make sure Bugzilla 22006 stays fixed.  On the
other hand if you want to WONTFIX that bad boy, I guess I don't have any
good grounds for objecting; the SMAP spec doesn't seem to say anywhere that
SMAPs need to be complete (or even non-empty?  Now there's a way to save
ourselves a bunch of work...).

I see from another message that you've committed a fix for this.  I'll test
your code when I get a chance.

Eric


- Original Message - 
From: Kin-Man Chung [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, September 22, 2003 1:00 PM
Subject: Re: cvs commit:
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler
Generator.java Node.java SmapStratum.java SmapUtil.java


 The actual mapping before we optimize the smap is

 1:41
 2:42
 6:43
 6:44
 8:45
 8:46

 which looks OK to me.  But since we only do the smap at the beginnig of
 the template text, and assume the the input line count is 1, the result is
 what you have noticed.

 I'll see if I can add some code to compute the input line ranges, but
 it is going to be messy.  :(

 But really, all this is more academic than useful in practice: who do
 you think may need to single step over template text lines?  :-)

 -Kin-man

  Date: Sat, 20 Sep 2003 00:18:14 -0700
  From: Eric Carmichael [EMAIL PROTECTED]
  Subject: Re: cvs commit:
 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler
 Generator.java Node.java SmapStratum.java SmapUtil.java
  X-Originating-IP: [64.203.49.21]
  To: Tomcat Developers List [EMAIL PROTECTED]
  X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
  X-Priority: 3
  X-MSMail-priority: Normal
  X-Originating-Email: [EMAIL PROTECTED]
  X-OriginalArrivalTime: 20 Sep 2003 07:18:18.0787 (UTC)
 FILETIME=[5DB22F30:01C37F47]
 
  cal/cal1.jsp from the jsp-examples webapp starts like this:
 
  HTML
  !-- 
Copyright (c) 1999 The Apache Software Foundation. All rights
reserved.
  --
  HEADTITLE
 
  Before this commit, cal1.jsp's SMAP started like this:
 
  *L
  1,2:41
  3:42
  4:42
  5:42
  6:43,2
 
  Now it starts like this:
 
  *L
  1,2:41
  6:43,2
 
  I think the reason lines 3, 4, and 5 aren't being SMAPped is that you
only add
 LineInfos inside if (breakAtLF || count  0) {.  This adds LineInfos
when the
 output line advances, but not when the input line alone advances.  To SMAP
 template text fully, you have to add a LineInfo every time the line number
 advances in the input file or the output file.
 
  Eric
 
 
  - Original Message - 
  From: [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Tuesday, September 16, 2003 10:46 AM
  Subject: cvs commit:
 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler
 Generator.java Node.java SmapStratum.java SmapUtil.java
 
 
   kinman  2003/09/16 10:46:44
  
 Modified:jasper2/src/share/org/apache/jasper/compiler
Generator.java
   Node.java SmapStratum.java SmapUtil.java
 Log:
 - For template texts that generate multiple Java lines, addidtional
 mapping
   informantion are kept in the TemplateText node, to aide SMAP
generation.
  
 Revision  ChangesPath
 1.208 +23 -14

jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator
.jav
 a
  
 Index: Generator.java
 ===
 RCS file:

/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler
/Gen
 erator.java,v
 retrieving revision 1.207
 retrieving revision 1.208
 diff -u -r1.207 -r1.208
 --- Generator.java 15 Sep 2003 13:43:54 - 1.207
 +++ Generator.java 16 Sep 2003 17:46:43 - 1.208
 @@ -1867,21 +1867,25 @@
  return;
  }
  
 -if (ctxt.getOptions().genStringAsCharArray()) {
 -if (textSize = 3) {
 -   // Spcial case small text strings
 -   n.setBeginJavaLine(out.getJavaLine());
 -   out.printil(out.write( + quote(text.charAt(0))
+
 ););
 -   if (textSize  1) {
 -   out.printil(out.write( +
quote(text.charAt(1)) +
 ););
 +if (textSize = 3) {
 +   // Special case small text strings
 +   n.setBeginJavaLine(out.getJavaLine());
 +   int lineInc = 0;
 +   for (int i = 0; i  textSize; i++) {
 +   char ch = text.charAt(i);
 +   out.printil(out.write( + quote(ch) + ););
 +   if (i  0) {
 +   n.addSmap(lineInc);
 }
 -   if (textSize  2) {
 -   out.printil(out.write( +
quote(text.charAt(2)) +
 ););
 +   if (ch

Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2003-09-20 Thread Eric Carmichael
This SMAPs all declaration nodes, including the ones tacked on to the root node by 
ELFunctionMapper.java.  So for instance the SMAP for jsp2/el/functions.jsp from the 
jsp-examples webapp ends with

43,6:120
1,3:10
1,5:13

thus SMAPping 

  %@ taglib prefix=my uri=http://jakarta.apache.org/tomcat/jsp2-example-taglib%

to

  static private org.apache.jasper.runtime.ProtectedFunctionMapper _jspx_fnmap_0;
  static private org.apache.jasper.runtime.ProtectedFunctionMapper _jspx_fnmap_1;

and

  static {
_jspx_fnmap_0= 
org.apache.jasper.runtime.ProtectedFunctionMapper.getMapForFunction(my:reverse, 
jsp2.examples.el.Functions.class, reverse, new Class[] {java.lang.String.class});
_jspx_fnmap_1= 
org.apache.jasper.runtime.ProtectedFunctionMapper.getMapForFunction(my:countVowels, 
jsp2.examples.el.Functions.class, numVowels, new Class[] {java.lang.String.class});
  }

which is clearly wrong.

Eric

- Original Message - 
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, September 19, 2003 4:38 PM
Subject: cvs commit: 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java


 kinman  2003/09/19 16:38:09
 
   Modified:jasper2/src/share/org/apache/jasper/compiler Generator.java
   Log:
   - Make sure scriptlet declarations get properly mapped.  This fixes 22833
   
   Revision  ChangesPath
   1.211 +7 -6  
 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java
   
   Index: Generator.java
   ===
   RCS file: 
 /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
   retrieving revision 1.210
   retrieving revision 1.211
   diff -u -r1.210 -r1.211
   --- Generator.java 19 Sep 2003 18:30:09 - 1.210
   +++ Generator.java 19 Sep 2003 23:38:08 - 1.211
   @@ -196,9 +196,7 @@
 */
public void visit(Node.PageDirective n) throws JasperException {

   -if (!getServletInfoGenerated) {
   -getServletInfoGenerated = true;
   -} else {
   +if (getServletInfoGenerated) {
return;
}

   @@ -206,6 +204,7 @@
if (info == null)
return;

   +getServletInfoGenerated = true;
out.printil(public String getServletInfo() {);
out.pushIndent();
out.printin(return );
   @@ -217,8 +216,10 @@
}

public void visit(Node.Declaration n) throws JasperException {
   +n.setBeginJavaLine(out.getJavaLine());
out.printMultiLn(new String(n.getText()));
out.println();
   +n.setEndJavaLine(out.getJavaLine());
}

// Custom Tags may contain declarations from tag plugins.
   
   
   
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 

Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2003-09-11 Thread Remy Maucherat
[EMAIL PROTECTED] wrote:
kinman  2003/09/10 16:11:56

  Modified:jasper2/src/share/org/apache/jasper/compiler Generator.java
  Log:
  - Use out.print(expr) instead of out.write(String.valueOf(expr)) for outputting
expressions in template texts.
The problem was when the expression was null, if I remember well the 
original justification for String.valueOf (of course, it is IMO 
acceptable to raise a NPE).

Remy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2003-09-11 Thread Kin-Man Chung
Yeah, now I remember; but I didn't pay attention then!  :-)

Anyway, the print methods handle null String and Object, so we are covered.
This is true for outputting expressions in text mode; evaluating attributes
with expressions is, however, another matter.

BTW, I also think it acceptable to raise NPE.  Let's leave print's in
until someone else objects!  :-)

-Kin-man

 Date: Thu, 11 Sep 2003 08:53:36 +0200
 From: Remy Maucherat [EMAIL PROTECTED]
 Subject: Re: cvs commit: 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler 
Generator.java
 To: Tomcat Developers List [EMAIL PROTECTED]
 
 [EMAIL PROTECTED] wrote:
  kinman  2003/09/10 16:11:56
  
Modified:jasper2/src/share/org/apache/jasper/compiler Generator.java
Log:
- Use out.print(expr) instead of out.write(String.valueOf(expr)) for 
outputting
  expressions in template texts.
 
 The problem was when the expression was null, if I remember well the 
 original justification for String.valueOf (of course, it is IMO 
 acceptable to raise a NPE).
 
 Remy
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2002-09-05 Thread Richard Atkinson


Thanks Remy, I was just looking at possible fixes.
Bad design, maybe.  I'll bear it in mind and review
my usage.

Regards,
Richard...

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 05, 2002 10:39
To: [EMAIL PROTECTED]
Subject: cvs commit:
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler
Generator.java


remm2002/09/05 02:39:16

  Modified:jasper2/src/share/org/apache/jasper/compiler Tag:
tomcat_4_branch Generator.java
  Log:
  - Force the convesion of the value to a string.
  - Note: I am not convinced this is a compliance issue (and it looks like
bad design
to pass an object or null); this just reverts back the old behavior.
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.35.2.6  +4 -4
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator
.java
  
  Index: Generator.java
  ===
  RCS file:
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler
/Generator.java,v
  retrieving revision 1.35.2.5
  retrieving revision 1.35.2.6
  diff -u -r1.35.2.5 -r1.35.2.6
  --- Generator.java28 Aug 2002 20:47:57 -  1.35.2.5
  +++ Generator.java5 Sep 2002 09:39:16 -   1.35.2.6
  @@ -563,7 +563,7 @@
   
if (attr.isExpression()) {
if (encode) {
  - return java.net.URLEncoder.encode( + v + );
  + return java.net.URLEncoder.encode(\\ +  + v + );
}
return v;
} else {
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]



This email with all information contained herein or attached hereto may
contain confidential and/or privileged information intended for the
addressee(s) only.  If you have received this email in error, please contact
the sender and immediately delete this email in its entirety and any
attachments thereto.



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2002-09-05 Thread Paul Speed

   + return java.net.URLEncoder.encode(\\ +  + v + );

I know I'm being pedantic, but it's a small pet peeve of mine. :)
How about:
  return java.net.URLEncoder.encode( String.valueOf(v) );

Should do the same thing without all the behind-the-scenes 
StringBuffer stuff.

-Paul Speed

[EMAIL PROTECTED] wrote:
 
 remm2002/09/05 04:27:20
 
   Modified:jasper2/src/share/org/apache/jasper/compiler Generator.java
   Log:
   - Force the convesion of the value to a string.
   - Note: I am not convinced this is a compliance issue (and it looks like bad design
 to pass an object or null); this just reverts back the old behavior.
 
   Revision  ChangesPath
   1.90  +4 -4  
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java
 
   Index: Generator.java
   ===
   RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
   retrieving revision 1.89
   retrieving revision 1.90
   diff -u -r1.89 -r1.90
   --- Generator.java4 Sep 2002 23:45:29 -   1.89
   +++ Generator.java5 Sep 2002 11:27:19 -   1.90
   @@ -749,7 +749,7 @@
 _jspx_fnmap );
 }
 if (encode) {
   - return java.net.URLEncoder.encode( + v + );
   + return java.net.URLEncoder.encode(\\ +  + v + );
 }
 return v;
} else if( attr.isNamedAttribute() ) {
 
 
 
 
 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java

2002-09-05 Thread Paul Speed



Paul Speed wrote:
 
+ return java.net.URLEncoder.encode(\\ +  + v + );
 
 I know I'm being pedantic, but it's a small pet peeve of mine. :)
 How about:
   return java.net.URLEncoder.encode( String.valueOf(v) );

So much for attention to details...  
return java.net.URLEncoder.encode( String.valueOf( + v + ) );

-Paul

 
 Should do the same thing without all the behind-the-scenes
 StringBuffer stuff.
 
 -Paul Speed
 
 [EMAIL PROTECTED] wrote:
 
  remm2002/09/05 04:27:20
 
Modified:jasper2/src/share/org/apache/jasper/compiler Generator.java
Log:
- Force the convesion of the value to a string.
- Note: I am not convinced this is a compliance issue (and it looks like bad 
design
  to pass an object or null); this just reverts back the old behavior.
 
Revision  ChangesPath
1.90  +4 -4  
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java
 
Index: Generator.java
===
RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -r1.89 -r1.90
--- Generator.java4 Sep 2002 23:45:29 -   1.89
+++ Generator.java5 Sep 2002 11:27:19 -   1.90
@@ -749,7 +749,7 @@
  _jspx_fnmap );
  }
  if (encode) {
- return java.net.URLEncoder.encode( + v + );
+ return java.net.URLEncoder.encode(\\ +  + v + );
  }
  return v;
 } else if( attr.isNamedAttribute() ) {
 
 
 
 
  --
  To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
  For additional commands, e-mail: mailto:[EMAIL PROTECTED]
 
 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]