Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    [JSP] errore in lettura XML (Content is not allowed in prolog.)

    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 è:
    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"  />
    			
      
    			<x:out select="$n/author"  />  
    			
    
    			
      
    		</x:forEach>
    	</body
    </html>
    Mentre l'XML è:
    codice:
    <?xml version="1.0" ?>
    <books>            
    	<book> 
    		<title>cobol</title> 
    		<author>roy</author> 
    	</book> 
       	<book> 
    		<title>java</title> 
    		<author>herbert</author> 
    	</book> 
    </books>
    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.handle JspException(JspServletWrapper.java:527)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:401)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.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.doHandle PageException(PageContextImpl.java:858)
    org.apache.jasper.runtime.PageContextImpl.handlePa geException(PageContextImpl.java:791)
    org.apache.jsp.index2_jsp._jspService(index2_jsp.j ava:91)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:377)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.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.DOMPars er.parse(Unknown Source)
    com.sun.org.apache.xerces.internal.jaxp.DocumentBu ilderImpl.parse(Unknown Source)
    org.apache.taglibs.standard.tag.common.xml.ParseSu pport.parseInputSource(Unknown Source)
    org.apache.taglibs.standard.tag.common.xml.ParseSu pport.parseInputSourceWithFilter(Unknown Source)
    org.apache.taglibs.standard.tag.common.xml.ParseSu pport.parseReaderWithFilter(Unknown Source)
    org.apache.taglibs.standard.tag.common.xml.ParseSu pport.parseStringWithFilter(Unknown Source)
    org.apache.taglibs.standard.tag.common.xml.ParseSu pport.doEndTag(Unknown Source)
    org.apache.jsp.index2_jsp._jspx_meth_x_005fparse_0 05f0(index2_jsp.java:140)
    org.apache.jsp.index2_jsp._jspService(index2_jsp.j ava:77)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:377)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:717

    Qualcuno sa darmi una soluzione?
    Grazie in anticipo

  2. #2
    UP

  3. #3
    se dovesse servire a qualcun'altro aggiungendo i jar di xalan si è risolto tutto

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.