Hello,

I've a newbie to JSP so I apologize if this is an obvious error on my part. I've been banging my head against this problem for a while and I can't seem to figure it out, though. Any help appreciated.

I'm trying to create a web app that so far is pretty basic. The web page will consist of various sections, laid out using <div>s. E.g header, horizontal navigation bar, sidebar, main content, footer, etc. Since each of the divs will always be present (just with different content, depending on what the user is trying to do), I've broken the various pages up into .jsp fragments that I use to build up each page. So for example my 'home.jsp' looks like:

<%@ include file="content_open.jsp" %>
<%@ include file="home_main.jsp" %>
<%@ include file="home_local.jsp" %>
<%@ include file="home_sub.jsp" %>
<%@ include file="navigation.jsp" %>
<%@ include file="content_close.jsp" %>

So for example, 'content_open.jsp' looks like:

<%@ page contentType="text/html" session="true" %>

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

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>My title</title>
    
    <style type="text/css" media="screen">
        @import url("css/tools.css");
        @import url("css/typo.css");
        @import url("css/forms.css");
        @import url("css/layout-navtop-localleft.css");
        @import url("css/layout.css");
    </style>
</head>
<body id="page-home">
    <div id="page">
        <div id="header" class="clearfix">
            <div id="branding">
                <img src="images/dolphin.png" width="100" height="70" alt="alternate" />
            </div><!-- end branding -->
            <hr />
        </div><!-- end header -->
        
        <div id="content" class="clearfix">

Then 'home_main.jsp' will fill in the <div id="content> div, etc. All this seems to work fine until I added the JSTL taglib line to 'content_open.jsp' (hightlighted in red above). This gives me the following error:

org.apache.jasper.JasperException: <h3>Validation error messages from TagLibraryValidator for c in /home.jsp</h3><p>null: org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x0) was found in the CDATA section.</p>
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:74)
org.apache.jasper.compiler.Validator.validateXmlView(Validator.java:1542)
org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1487)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:188)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

The strange thing is that if I create a really micky mouse example to test, everything works. I can't seem to pinpoint exactly what it doesn't like about my slightly more complex example above.

If the other .jsp fragments are needed I can post those too. Just wondering if this is a known issue or if I'm doing something obviously wrong.

Again, any help appreciated.

Bill

IMO, the error is exactly what the trace says it is; it has found an illegal non-visual character in your markup.

Are you sure the error comes *only* when you put the taglib include and works otherwise? If yes, then instead of copy-pasting that line try typing it out. BTW, you are using an old version of JSTL; the uri should be http://java.sun.com/jsp/jstl/core .

IMO, the error is exactly what the trace says it is; it has found an illegal non-visual character in your markup.

Are you sure the error comes *only* when you put the taglib include and works otherwise? If yes, then instead of copy-pasting that line try typing it out. BTW, you are using an old version of JSTL; the uri should be http://java.sun.com/jsp/jstl/core .

Thanks for the reply. And yes, I'm positive the problem goes away if I remove the line. I have also tried retyping it by hand with no luck. As I said, though, the exact same line cut and pasted into a mickey mouse example, works just fine. Really getting frustrated w/ this one because this seems so basic.

Regarding, the version, I lifted my jars and <taglib> entries in the web.xml from an older project so yes, it is possible that I'm using an older version. Is there a standard place to get the latest version?

Also FWIW, I'm using Apache Tomcat 5.5.28 running in a Windows 7 environment.

Regards,

Bill

It seems as though placing a taglib declaration triggers some kind of taglib validation in action which blows up when it encounters a problem. Does this problem come with only the above mentioned JSP or does it happen with all the JSP's? If it happens only for the above mentioned JSP, you might have to run it through a sanitizer script which strips all the characters unacceptable by the XML specification. You can try this link for the same.

You can get the latest JSTL API + implementation here.

It seems as though placing a taglib declaration triggers some kind of taglib validation in action which blows up when it encounters a problem. Does this problem come with only the above mentioned JSP or does it happen with all the JSP's? If it happens only for the above mentioned JSP, you might have to run it through a sanitizer script which strips all the characters unacceptable by the XML specification. You can try this link for the same.

You can get the latest JSTL API + implementation here.

Thanks so much for the reply. I finally figured it out. You were correct, there was a spurious control character at the end of my 'content_close.jsp' file. Once I spotted it and removed it, things started working again. The odd thing -- and the thing that lead me astray -- was the fact that it only got triggered when I added the taglib directive so I kept thinking there was something wrong with that. I don't know what that is all about but perhaps this thread will save somebody some pain in the future. Also, your suggestion that I may not be using the latest and greatest JSTL prompted me to go and get it from the GlassFish site you gave above so it was not all for nought.

Thanks for all the help.

Bill

commented: Glad it worked out for you. :-) +13
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.