Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6041657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:41:35+00:00 2026-05-23T06:41:35+00:00

I find JSP works great in HTML but I often have problems using it

  • 0

I find JSP works great in HTML but I often have problems using it to generate Javascript. This code isn’t working, and in fact the page crashes when I try to inspect the element with Chrome’s debugging tools:

var sensorData = [[
                        <c:forEach items="${tableData}" var="val" varStatus="status">
                            <c:set var="tempStr" value="X"/>

                            <c:choose>
                                <c:when test="${!fn:contains(val, tempStr)}">
                                    <fmt:formatNumber value="${val}" maxFractionDigits="0"/>
                                </c:when>
                                <c:otherwise>
                                    ${val}
                                </c:otherwise>
                            </c:choose>

                            <c:choose>
                                <c:when test="${(status.index + 1) % width == 0 && !status.last}">
                                    ],[
                                </c:when>
                                <c:when test="${status.last}">
                                    ]
                                </c:when>
                                <c:otherwise>
                                    ,
                                </c:otherwise>
                            </c:choose>


        </c:forEach>
                 ];

Here I’d like to create a 2d array with tableData, an ArrayList. Eclipse is showing errors on the first <c:when>:

Syntax error, insert "]" to complete ArrayLiteral

Can anyone see what I’m doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:41:36+00:00Added an answer on May 23, 2026 at 6:41 am

    If some of the array values are strings, then that’s you’re problem — you have to quote them.

            <c:otherwise>
                "${val}"
            </c:otherwise>
    

    Now you’re also going to have to worry about string values that contain quotes and other meta-characters in JavaScript’s string constant token syntax. I use my own EL function for “protecting” string contents, kind-of analogous to fn:escapeXml(). Unfortunately Java is frozen in time so there’s no built-in support for generating JSON, which would obviate this entire exercise. (I also have my own EL function for that, of course, because it’s really not very hard for non-exotic data structures.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the wysihat-engine on my jsp. It works well, but when I tried
I'm a c# developer but have a job that involves some jsp code. I've
We have 600 jsp files and I need to find out where we are
I am just starting with coding some JSP, which I find isn't all that
enter code hereHiya, so far I didn't use JSP at all and I find
I have a JSP page that renders a block of HTML. In normal usage,
I have searched this web looking for an answer, but it seems that this
I'm having trouble with a custom tag:- org.apache.jasper.JasperException: /custom_tags.jsp(1,0) Unable to find setter method
Having replaced a <jsp:forward page=URL> with a response.sendRedirect(URL); , I find I know lose
find whether there is a loop in a linked list. Do you have other

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.