1

I have a very strange problem.

    <table border ="1">
                        <tbody>
                            <c:forEach var="question" items="${questions}">                                
                                <tr>
                                    <td>
                                        ${question.getQuestion()}                                     
                                    </td>
                                    <td> 
                                        <c:forEach var="answer" items="${question.getAnswers()}">                                                      
                                            <input type="checkbox" name ="user_answer" value="${answer.getAnswer()}">
                                            ${answer.getAnswer()}
                                            <br />
                                        </c:forEach>                                   
                                    </td>
                                    <td>
                                    <a href="/TutorWebApp/controller?command=edit_qestion&amp;question=${question}">
                                           Edit 
                                    </a>
                                    </td>
                                </tr>
                            </c:forEach>                  
                        </tbody>
</table>

But If I use in I get next error error_image

But if I don't use tag <a> in <td> it's OK. I don't have any ideas. Thanks

Ray
  • 1,788
  • 7
  • 55
  • 92
  • @TonyEnnis **Bad value "/TutorWebApp/controller?command=edit_qustion= "for attribute "href" on element "a": DOUBLE_WHITESPACE in QUERY.** – Ray May 06 '12 at 07:11

3 Answers3

1

I think this is just a bug/limitation of your editor. Try deploying your JSP and see if it works as expected or not.

That said, if your question contains characters that must be URL and/or HTML escaped, your HTML code will be invalid. You should use the c:url tag to avoid that:

<c:url var="editQuestionUrl" value="/TutorWebApp/controller">
    <c:param name="command" value="edit_question"/>
    <c:param name="question" value="${question}"/>
</c:url>
<%-- now the params are url-encoded --%>
<a href="${fn:escapeXml(editQuestionUrl)}">Edit</a>
<%-- now the query string is HTML-escaped --%>
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
0

try replacing this line

<a href="/TutorWebApp/controller?command=edit_qestion&amp;question=${question}">

with

<a href="/TutorWebApp/controller?command=edit_qestion&amp;question='${question}'">
Satya
  • 8,693
  • 5
  • 34
  • 55
  • Now I have a new error **WHITESPACE in QUERY**. Maybe it's better than DOUBLE)) – Ray May 06 '12 at 07:16
0

You need to encode your question text (or whole URL) here by calling URLEncoder#encode()

You can look at this Q&A on how to encode a URL in JSTL.

Alternatively you can try calling JSTL's escapeXml function on your question text.

Community
  • 1
  • 1
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • JSTL's escapeXml doesn't help in this problem( – Ray May 06 '12 at 07:25
  • This is an issue with netbeans HTML checker not recognizing the other language inside the href. It pops up the same bogus error for = ?> PHP values. – Mantriur Aug 21 '12 at 02:05