Mantis - Resin
Viewing Issue Advanced Details
899 minor always 01-26-06 14:44 04-03-06 18:38
koreth  
ferg  
normal  
closed 3.0.17  
fixed  
none    
none 3.0.19  
0000899: Setting to control formatting of nulls in JSP pages
WebLogic has a config setting to make "<%= foo %>" do nothing if foo is null (rather than outputting the string "null"). We have a bunch of legacy JSPs that depend on this behavior. For now I've just hacked AbstractBodyContent to get rid of the code that outputs "null", but it would be nice if this were controlled by a configuration setting.

Notes
(0000790)
koreth   
01-26-06 14:51   
Here's the patch for my change -- I am *not* suggesting this be incorporated into the main release, but this may save someone else some time if they look at this bug report wondering how to do the same thing.

--- modules/resin/src/com/caucho/jsp/AbstractBodyContent.java- 2006-01-26 14:17:17.959091586 -0800
+++ modules/resin/src/com/caucho/jsp/AbstractBodyContent.java 2006-01-26 14:17:49.934781032 -0800
@@ -49,7 +49,6 @@
 abstract class AbstractBodyContent extends AbstractJspWriter {
   private static final char []_trueChars = "true".toCharArray();
   private static final char []_falseChars = "false".toCharArray();
- private static final char []_nullChars = "null".toCharArray();

   private final char []_tempCharBuffer = new char[256];

@@ -215,9 +214,7 @@
    */
   final public void print(String s) throws IOException
   {
- if (s == null)
- write(_nullChars, 0, _nullChars.length);
- else
+ if (s != null)
       write(s, 0, s.length());
   }

@@ -226,9 +223,7 @@
    */
   final public void print(Object v) throws IOException
   {
- if (v == null)
- write(_nullChars, 0, _nullChars.length);
- else {
+ if (v != null) {
       String s = v.toString();

       write(s, 0, s.length());
@@ -329,9 +324,7 @@
    */
   final public void println(String s) throws IOException
   {
- if (s == null)
- write(_nullChars, 0, _nullChars.length);
- else
+ if (s != null)
       write(s, 0, s.length());

     println();
@@ -342,9 +335,7 @@
    */
   final public void println(Object v) throws IOException
   {
- if (v == null)
- write(_nullChars, 0, _nullChars.length);
- else {
+ if (v != null) {
       String s = String.valueOf(v);

       write(s, 0, s.length());
(0001005)
ferg   
04-03-06 18:38   
jsp/15g2