tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eduardo Pelegri--Llopart <Eduardo.Pelegrillop...@eng.sun.com>
Subject Re: [PROPOSAL] Jasper, Use XML parser to improve error reporting of JSP taglib problems
Date Tue, 25 Jul 2000 14:27:20 GMT
Glenn:

A feature like this is being discussed right now within the JSP 1.2
expert group.  Thanks for your suggestion and please check the public
draft as it comes out and send us feedback as appropriate.

	- eduard/o


Glenn Nielsen wrote:
> 
> Problem:
> 
> When Jasper encounters an error when parsng a JSP which uses tag libraries,
> the errors often don't indicate what the real problem is and would be
> very confusing to non programmers.
> 
> Example when someone doesn't close a tag properly, i.e.
> they forget the '/' before the tag name when closing it:
> 
> Internal Servlet Error:
> 
> org.apache.jasper.JasperException: Unable to compile class for JSP
>         at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:456)
>         at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)
>         at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:413)
>         at
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:154)
>         at
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:166)
>         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:298)
>         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:371)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:370)
>         at org.apache.tomcat.core.Handler.service(Handler.java:262)
>         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:358)
>         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:719)
>         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:665)
>         at
> org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:169)
>         at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:393)
>         at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
>         at java.lang.Thread.run(Thread.java:479)
> Root cause:
> java.lang.ArrayIndexOutOfBoundsException: -1 < 0
>         at java.util.Vector.elementAt(Vector.java:419)
>         at org.apache.jasper.compiler.JspReader.getFile(JspReader.java:99)
>         at org.apache.jasper.compiler.JspReader.popFile(JspReader.java:237)
>         at org.apache.jasper.compiler.JspReader.hasMoreInput(JspReader.java:262)
>         at org.apache.jasper.compiler.JspReader.nextChar(JspReader.java:271)
>         at org.apache.jasper.compiler.JspReader.advance(JspReader.java:372)
>         at org.apache.jasper.compiler.Parser$Tag.accept(Parser.java:834)
>         at org.apache.jasper.compiler.Parser.parse(Parser.java:1070)
>         at org.apache.jasper.compiler.Parser.parse(Parser.java:1035)
>         at org.apache.jasper.compiler.Parser$Tag.accept(Parser.java:833)
>         at org.apache.jasper.compiler.Parser.parse(Parser.java:1070)
>         at org.apache.jasper.compiler.Parser.parse(Parser.java:1035)
>         at org.apache.jasper.compiler.Parser.parse(Parser.java:1031)
>         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:182)
>         at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:442)
>         at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)
>         at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:413)
>         at
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:154)
>         at
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:166)
>         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:298)
>         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:371)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:370)
>         at org.apache.tomcat.core.Handler.service(Handler.java:262)
>         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:358)
>         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:719)
>         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:665)
>         at
> org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:169)
>         at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:393)
>         at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
>         at java.lang.Thread.run(Thread.java:479)
> 
> Background:
> 
> Tag Lib Descriptor files (tld's) are well formed XML files.
> jsp: tags are well formed XML. (Is their a DTD for jsp: tags?)
> 
> Proposal:
> 
> Use an XML Parser to do validation of JSP pages which use a taglib.
> An XML Parser does a much better job of reporting malformed XML than
> Jasper does reporting errors when parsing tag lib elements.
> 
> Implementation:
> 
> Detect if one or more taglib directives are in jsp.
> 
> Load and validate tld's for taglibs, create a DTD for
> each tag lib. DTD's for taglibs should be cached by Jasper
> for later reuse.  Perhaps XSLT could be used to transform
> the tld into a dtd?
> 
> Strip any HTML and/or scriptlets from the JSP that are not
> inside an XML element, do not remove any lines so that any
> errors report the correct line numbers. A regexp can probably
> handle this.
> 
> Add the correct XML document headers to the stripped JSP.
> Each taglib being used in the JSP will have its own namespace.
> 
> Pass the document to a DOM parser and report back any errors.
> 
> Continue on with normal processing of JSP.
> 
> In the future the parsed document may come in handy for
> generating the servlet code.  But for now I am only interested
> in bettor error reporting.
> 
> Comments?
> 
> Regards,
> 
> Glenn
> 
> ----------------------------------------------------------------------
> Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
> MOREnet System Programming               |  * if iz ina coment.      |
> Missouri Research and Education Network  |  */                       |
> ----------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org

Mime
View raw message