I can't insert a basic HTML whitespace without getting an error. Is there any other way?

Carlos Sanchez picture Carlos Sanchez · Dec 4, 2010 · Viewed 8.1k times · Source

I have my implementation with spring, js, and other technologies, whenever i try to use a &nsbp for white space it gives me the following error:

Caused by: org.apache.jasper.JasperException: /WEB-INF/views/entrada/list.jspx(94,67) The entity "nbsp" was referenced, but not declared.

at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
    at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
    at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88)
    at org.apache.jasper.compiler.JspDocumentParser.parse(JspDocumentParser.java:216)
    at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:239)
    at org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:120)
    at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:165)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
    at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
    at org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:650)
    at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:644)
    at org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:103)
    ... 106 more

My code:

</td>
        <td>
            <c:forEach items="${entrada.tags}" var="tag">
            <spring:url value="/find/ByTags?tags=${tag.id}" var="buscarTag"/>
                <a href="${buscarTag}">${tag}</a> &nbsp;
            </c:forEach>
        </td>
         <td><input type="hidden" class="horasIn" value="${entrada.horas}"/>
         ${fn:substring(entrada.horas, 0, 10)}
         <c:set var="totalHoras" value="${totalHoras+ entrada.horas }"></c:set>bs

Answer

Ben Regenspan picture Ben Regenspan · Dec 4, 2010

Try referring to it as the entity number for non-breaking space, &#160;

&#160; is a numeric character reference and works across HTML and XML. &nbsp; is a character entity reference that is defined in HTML but not XML. You could think of the character reference as an alias to the numeric representation of the character, and in this case (XML) it happens that the alias is not defined.

"160" is the number of the Unicode code point for non-breaking space. You could also write the numeric character reference as &#x00a0; (same thing, but in hex)