tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vianen, Jeroen van" <jeroen.van.via...@satama.com>
Subject [standard] Null in Javascript scope patch
Date Thu, 20 Dec 2001 15:03:58 GMT
Hi,

I tried to use the EA3 release of the JSTL standard tag library in Resin
2.0.4.

My JSP more or less looks like this:

<%@ taglib uri="http://java.sun.com/jstl/ea/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/ea/xml" prefix="x" %>

<c:import url="http://localhost/path/to/file.xml" var="xml"/>
<x:parse source="$xml" var="doc" />
<x:forEach select="$doc/tic_stream/tic_bericht">
	<x:expr select="Weg" />
	... and some more XPath expressions
</x:forEach>


I was unable to get this to work due to the following exception:

TypeError: Cannot convert null to an object.
	at org.mozilla.javascript.NativeGlobal.constructError(Unknown
Source)
	at org.mozilla.javascript.NativeGlobal.constructError(Unknown
Source)
	at org.mozilla.javascript.NativeGlobal.typeError0(Unknown Source)
	at org.mozilla.javascript.ScriptRuntime.toObject(Unknown Source)
	at org.mozilla.javascript.Context.toObject(Unknown Source)
	at
org.apache.taglibs.standard.lang.javascript.JavascriptExpressionEvaluator.pu
tAttributesInScope(JavascriptExpressionEvaluator.java:159)
	at
org.apache.taglibs.standard.lang.javascript.JavascriptExpressionEvaluator.ev
aluate(JavascriptExpressionEvaluator.java:104)
	at
org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager.evaluate
(ExpressionEvaluatorManager.java:200)
	at
org.apache.taglibs.standard.tag.el.core.ExpressionUtil.evalNotNull(Expressio
nUtil.java:85)
	at
org.apache.taglibs.standard.tag.el.core.ImportTag.evaluateExpressions(Import
Tag.java:150)
	at
org.apache.taglibs.standard.tag.el.core.ImportTag.doStartTag(ImportTag.java:
101)
	at _traffic2__jsp._jspService(/pda/traffic2.jsp:19)
	at com.caucho.jsp.JavaPage.service(JavaPage.java:74)
	at com.caucho.jsp.Page.subservice(Page.java:485)
	at
com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:176)
	at com.caucho.server.http.Invocation.service(Invocation.java:278)
	at
com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:129)
	at
com.caucho.server.http.ServletServer.serviceTop(ServletServer.java:847)
	at
com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:213)
	at
com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:158)
	at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
	at java.lang.Thread.run(Thread.java:484)


It turned out that a null pointer was stored somewhere in the JavaScript
scope for the (null) attribute "caucho.authenticator", which is a built-in
Resin attribute.

Below is a patch for
.../standard/src/org/apache/taglibs/standard/lang/javascript/JavascriptExpre
ssionEvaluator.java that fixed this bug for me. I don't know whether this is
the correct fix, but at least I was able to have my JSP working as I
expected.


--- JavascriptExpressionEvaluator.java.orig     Thu Dec 20 15:48:57 2001
+++ JavascriptExpressionEvaluator.java  Thu Dec 20 15:57:09 2001
@@ -156,7 +156,9 @@
         while (attributes !=null && attributes.hasMoreElements()) {
             attribute = (String)attributes.nextElement();
             value = pageContext.getAttribute(attribute, scope);
-            rhinoScope.put(attribute, rhinoScope,
rhinoContext.toObject(value, rhinoScope));
+            if (value != null) {
+                rhinoScope.put(attribute, rhinoScope,
rhinoContext.toObject(value, rhinoScope));
+            }
         }
     }
 
@@ -174,7 +176,9 @@
         while (attributes !=null && attributes.hasMoreElements()) {
             attribute = (String)attributes.nextElement();
             value = (pageContext.getRequest()).getParameter(attribute);
-            rhinoScope.put(attribute, rhinoScope,
rhinoContext.toObject(value, rhinoScope));
+            if (value != null) {
+                rhinoScope.put(attribute, rhinoScope,
rhinoContext.toObject(value, rhinoScope));
+            }
         }
     }
 }


Please review,


Jeroen

--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message