Search code examples
htmleclipsejspglassfishjava-ee-6

Parsing JSP page, an error notifies well-formedness violation


I've got a JSP page. The technologies that I use to write/display it are the following:

  • Glassfish 3 (based on Java EE 6)
  • Eclipse EE Kepler IDE
  • JDK v7

Here comes the page:

 <?xml version="1.0" encoding="UTF-8"?>
<% @page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
</head>
<body>
<h1> <center>506</center></h1>
<p/>
<h3>My fancy cat has been caught</h3>
<%
out.println("kkkkkkkkkkkkkkkkk");
%>

</body>
</html

The error occurs on the following line:

<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

The IDE says:

  • XML document is not well-formed due to a parsing error
  • The markup in the document preceding the root element must be well-formed

If I pass the document to the XML validator:http://www.validome.org/xml/validate/, it reports that:

  • The markup in the document preceding root element must be well-formed.
  • And that the error occurs on the % character. Although, it says that the column is number 3. Yet, looking at the document, the column appears to be at number 2 (no space in front of line). The other validator reports the same thing, in terms of column number.

The HTML/JSP document is XML constrained, yet it is not completely XML document, and I assume that is why the validator does not recognize the JSP syntax.

The other thing, is that, the next error occurs on the following line:

<%
out.println("kkkkkkkkkkkkkkkkk");
%>

The IDE again complains that, on this character, %:

  • The content of elements must consists of well-formed character data or markup.

In fact, when I execute the page on the Glassfish app server, it displays the contents correctly. The same error occurs even if I change the app server to Glassfish 4 (based on Java EE 7). In addition to that, if I generate the JSP page from the template (available at the IDE), the same error, at the top, reoccurs.

If I type simply the HTML page, the error does not appear. For some reasons the IDE does not accept the JSP syntax.

I need to get fixed it, because, as long this error occurs, I cannot use contents assistant. Which is very helpful working with the page.

Any ideas, what might be the cause of this err?


Solution

  • Well, I come up with the solution. I've replaced the IDE with a fresh install, and the problems have disappeared. The only things that worked out for me on the previous IDE, is that, if you want to use the <jsp:scriplet> in a JSP page you need the following name-space on your root: xmlns:jsp="http://j‌​ava.sun.com/JSP/Page"‌.

    Moving forward...