Ciao a tutti,
premettendo la niubbagine sull'argomento, ho un problema con il caricamento di un documento XML in JSP.
Il codice l'ho preso da un esempio banale riportato in tantissimi forum/libri/documenti quindi non capisco perchè non funzioni.
Il file JSP è:
Mentre l'XML è:
In esecuzione l'errore che ricevo è il seguente:
exception
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: org.xml.sax.SAXParseException: Content is not allowed in prolog.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:527)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: org.xml.sax.SAXParseException: Content is not allowed in prolog.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.index2_jsp._jspService(index2_jsp.java:91)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
org.xml.sax.SAXParseException: Content is not allowed in prolog.
com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseInputSource(Unknown Source)
org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseInputSourceWithFilter(Unknown Source)
org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseReaderWithFilter(Unknown Source)
org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseStringWithFilter(Unknown Source)
org.apache.taglibs.standard.tag.common.xml.ParseSupport.doEndTag(Unknown Source)
org.apache.jsp.index2_jsp._jspx_meth_x_005fparse_005f0(index2_jsp.java:140)
org.apache.jsp.index2_jsp._jspService(index2_jsp.java:77)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717
Qualcuno sa darmi una soluzione?
Grazie in anticipo
premettendo la niubbagine sull'argomento, ho un problema con il caricamento di un documento XML in JSP.
Il codice l'ho preso da un esempio banale riportato in tantissimi forum/libri/documenti quindi non capisco perchè non funzioni.
Il file JSP è:
Codice:
<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
<html>
<body>
<c:import url="books.xml" var="url" />
<x:parse xml="${url}" var="doc" />
<x:forEach var="n" select="$doc/books/book">
<x:out select="$n/title" />
<br>
<x:out select="$n/author" />
<br>
<br>
</x:forEach>
</body
</html>
Codice:
<?xml version="1.0" ?>
<books>
<book>
<title>cobol</title>
<author>roy</author>
</book>
<book>
<title>java</title>
<author>herbert</author>
</book>
</books>
exception
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: org.xml.sax.SAXParseException: Content is not allowed in prolog.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:527)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: org.xml.sax.SAXParseException: Content is not allowed in prolog.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.index2_jsp._jspService(index2_jsp.java:91)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
org.xml.sax.SAXParseException: Content is not allowed in prolog.
com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseInputSource(Unknown Source)
org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseInputSourceWithFilter(Unknown Source)
org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseReaderWithFilter(Unknown Source)
org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseStringWithFilter(Unknown Source)
org.apache.taglibs.standard.tag.common.xml.ParseSupport.doEndTag(Unknown Source)
org.apache.jsp.index2_jsp._jspx_meth_x_005fparse_005f0(index2_jsp.java:140)
org.apache.jsp.index2_jsp._jspService(index2_jsp.java:77)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717
Qualcuno sa darmi una soluzione?
Grazie in anticipo