error page in jsp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • devgupta01
    New Member
    • Jan 2008
    • 20

    #1

    error page in jsp

    I have two files - test.jsp and error.jsp
    <<test.jsp>>
    <%@ page errorPage="/error.jsp" %>
    <%
    int a[] = {3,2,1};
    a[3]=100;
    %>
    <%= a[1] %>
    <<error.jsp>>
    <%@ page isErrorPage="tr ue" import="java.io .*" %>
    <html>
    <head><title>Er ror Page.</title></head>
    <body bgcolor="blue">
    <font size="16" color="white">Y our page generated an error:"<br/>
    Exception:<br/>
    <%= exception %></font>
    </body>
    </html>
    when i send the request to page test.jsp then it gives HTTP 500 Internal Server Error.

    I get error only if I first change a[3] to a[2] in file test.jsp and enter the url for test.jsp(this gives output on browser) and then I change back a[2] to a[3] and enter url for test.jsp in same browser.

    So I want to know where is the problem exactly.
  • chaarmann
    Recognized Expert Contributor
    • Nov 2007
    • 785

    #2
    Maybe your error page isn't in path "/" ?
    Just put full path for "<%@ page errorPage="/error.jsp" %>"

    Maybe you have an error in the error page itself?
    I can see "<%= exception %>", but object/string exception isn't defined.

    By the way, if you put "a[3]=100;", then you are causing an error, because the index only goes from 0 to 2.
    (Your array holds 3 elements, the first at a[0], the second at a[1], the third and last at a[2])

    Comment

    • devgupta01
      New Member
      • Jan 2008
      • 20

      #3
      Yes I get error "ArrayIndexOutO fBound:3" only if I first change a[3] to a[2] in file test.jsp and enter the url for test.jsp(this gives output on browser) and then I change back a[2] to a[3] and enter url for test.jsp in same browser.

      Thanks for ur reply...chaarma nn

      Comment

      Working...