• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

JSTL-XML problem

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:out select="$n/title" />
</tr>
<tr>
<x:out 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
 
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Onion rings are vegetable donuts. Taste this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic