views:

40

answers:

1

javax.servlet.jsp.JspTagException: 'begin' < 0

Once in a while you run into an error and you say: What the WHAT?? tagexception begin < 0. Seen this wonder before??

A: 

I tried to reproduce your exception with the following snippet:

<c:forEach begin="-1" end="1">
    <p>blah
</c:forEach>

I however got a much clearer and self-explaining exception trace in Tomcat's default error page:

org.apache.jasper.JasperException: An exception occurred processing JSP page /jsp.jsp at line 12

9:     <body>
10:         
11: 
12: <c:forEach begin="-1" end="1">
13: <p>bla
14: </c:forEach>
15: 


Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

javax.servlet.ServletException: javax.servlet.jsp.JspTagException: 'begin' < 0
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
    org.apache.jsp.jsp_jsp._jspService(jsp_jsp.java:74)
    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:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

javax.servlet.jsp.JspTagException: 'begin' < 0
    javax.servlet.jsp.jstl.core.LoopTagSupport.validateBegin(LoopTagSupport.java:478)
    org.apache.taglibs.standard.tag.rt.core.ForEachTag.setBegin(ForEachTag.java:55)
    org.apache.jsp.jsp_jsp._jspx_meth_c_005fforEach_005f0(jsp_jsp.java:90)
    org.apache.jsp.jsp_jsp._jspService(jsp_jsp.java:65)
    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:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs.

Probably there's something wrong with your exception handling or interpretation? It much look like that you're only printing/displaying the e.getMessage() of the root cause in some customized error page and ignoring the remnant of the information of the stacktrace. I'd suggest to add a e.printStackTrace() so that it's at least clear where it is coming from.

BalusC