Hi

I'm new to JSTL and not quite new to Java. I think JSTL is the best thing
since sliced bread :-)  but I'm having a problem. Probably this is a very
dumb question, but anyway...
(I tried the examples and they all work)

All I'm trying to do is set up a new iterator. Thus, I modify
org.apache.taglibs.standard.examples.startup.Init by copying
        /**
         * Array of Objects (String)
         */
        String[] stringArray = new String[] {
            "A first string",
            "La deuxieme string",
            "Ella troisiemo stringo",
        };
        sce.getServletContext().setAttribute("stringArray", stringArray);
and modifying it:
        /**
         * Array of Objects (String)
         */
        String[] stringArray = new String[] {
            "A first string",
            "La deuxieme string",
            "Ella troisiemo stringo",
        };
        sce.getServletContext().setAttribute("stringArray", stringArray);
        /**
         * Array of Objects (String)
         */
        String[] storyArray = new String[] {
            "A first string",
            "La deuxieme string",
            "Ella troisiemo stringo",
        };
        sce.getServletContext().setAttribute("storyArray", storyArray)

Then I modify DataTypes.jsp:
<h4>Array of objects (String)</h4>

<c:forEach var="string" items="$stringArray">
  <c:expr value="$string"/><br>
</c:forEach>
<c:forEach var="story" items="$storyArray">
  <c:expr value="$story"/><br>
</c:forEach>

I stop and restart Tomcat and open DataTypes.jsp in the browser, but I just
get the following error:
ReferenceError: "storyArray" is not defined.
        at org.mozilla.javascript.NativeGlobal.constructError(Unknown
Source)
        at org.mozilla.javascript.NativeGlobal.constructError(Unknown
Source)
        at org.mozilla.javascript.ScriptRuntime.name(Unknown Source)
        at org.mozilla.javascript.gen.c11.call(:0)
        at org.mozilla.javascript.gen.c11.exec()
        at org.mozilla.javascript.Context.evaluateReader(Unknown Source)
        at org.mozilla.javascript.Context.evaluateString(Unknown Source)
        at
org.apache.taglibs.standard.lang.javascript.JavascriptExpressionEvaluator.ev
aluate(JavascriptExpressionEvaluator.java:115)
        at
org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager.evaluate
(ExpressionEvaluatorManager.java:200)
        at
org.apache.taglibs.standard.tag.el.core.ForEachTag.evaluateExpressions(ForEa
chTag.java:196)
        at
org.apache.taglibs.standard.tag.el.core.ForEachTag.doStartTag(ForEachTag.jav
a:107)
        at org.apache.jsp.DataTypes$jsp._jspService(DataTypes$jsp.java:201)
        at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
etc. etc.

Probably I'm just being naive, but how exactly do you define a new object to
be used in JSTL? I couldn't find any further reference to the existing
stringArray in the source...

Best regards,
Eric
 

swissinfo/Swiss Radio International
Eric Lewis
IT Engineering
Giacomettistrasse 1
CH-3000 Berne 15

Phone:  ++41 31 350 95 42
Fax:    ++41 31 350 99 40
mailto:[EMAIL PROTECTED]

Switzerland is everywhere. Stay connected!
http://www.swissinfo.org 
http://mobile.swissinfo.org
http:/wap.swissinfo.org

SRG SSR idée suisse



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

Reply via email to