| Author |
JSTL-XML problem
|
kiranb reddy
Greenhorn
Joined: Sep 28, 2008
Posts: 20
|
|
jsp: <%@ page contentType="text/html"%> <%@taglib prefix="c" uri="http://java.sun.com/jstl/core"%> <%@taglib prefix="x" uri="http://java.sun.com/jstl/xml"%> <html> <body> <c:import url="/Sample/WEB-INF/books.xml" var="url" /> <x:parse xml="${url}" var="doc" /> <table border=1> <th> <tr> <td>title</td> <td>author</td> </tr> </th> <x:forEach var="n" select="$doc/books/book"> <td> <tr> <x ut select="$n/title" /> </tr> <tr> <x ut select="$n/author" /> </tr> </td> </x:forEach> </table> </body> </html> books.xml: <?xml version="1.0"?> <books> <book> <title>cobol</title> <author>roy</author> </book> </books> After deployment, when i access my jsp page: I got the error below: Can anybody explain the problem mentioned below: org.apache.jasper.JasperException: javax.servlet.jsp.JspException: Content is not allowed in prolog. org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355) 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:803) root cause javax.servlet.ServletException: javax.servlet.jsp.JspException: Content is not allowed in prolog. org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:837) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774) org.apache.jsp.xmldemo1_jsp._jspService(xmldemo1_jsp.java:95) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331) 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:803) Please help me to solve my problem. Thanks, Kiran
|
 |
Rachel Swailes
Ranch Hand
Joined: May 18, 2004
Posts: 434
|
|
|
You should check that the xml you are parsing is well formed. Also double check that the file path that you have given is correct and that the jsp can acually find that file.
|
 |
kiranb reddy
Greenhorn
Joined: Sep 28, 2008
Posts: 20
|
|
I have checked the path, its fine it is detecting, but i can't understand the well formed xml, can you explain some more in detail. But still, i am facing the same problem. if any example on JSTL-XML, please forward me. Kiran
|
 |
Rachel Swailes
Ranch Hand
Joined: May 18, 2004
Posts: 434
|
|
By well formed I mean, check that there is no blank line between the start of the file and the tag that opens with this <?xml version="1.0" . Check that you have a root element. The best idea actually is to run your xml through a validator such as this one - Xml Validator. You say that after deployment it fails. Do you mean that you are deploying to a server? Does your code work on your local development machine and not on the server or does your code not work on your local machine either?
|
 |
 |
|
|
subject: JSTL-XML problem
|
|
|