Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JSP - User defined error page not being displayed (newbie)

Status
Not open for further replies.

soumya73

Programmer
Sep 12, 2004
4
DE
Hi,

The simple example to capture a form value and display my error page under Tomcat 5.0 doesn't work. I have an errorhandler.jsp which looks like this -

-------------
<%@ page errorPage="errorpage.jsp" %>
<html>
<body>
<form method=post action="errorhandler.jsp">
What's the coolest programming language in the known universe ?<p>
Java<input type=radio name=language value="JAVA" checked>
C++<input type=radio name=language value="CPP">
Visual Basic<input type=radio name=language value="VB">
<p>
<input type=submit>
</form>

<%
if (request.getMethod().equals("POST")) {
if (request.getParameter("language").equals("JAVA")) {
out.println("<hr><font color=red>You got that right!</font>");
}
else {
throw new Exception("You chose the wrong language!");
}
}
%>

</body>
</html>
------------------

And an errorpage.jsp which looks like this -

--------------
<%@ page isErrorPage="true" %>
<html>
<body>
<h1>
Error Page
</h1>
<hr>
<h2>
Received the exception:<br>
<font color=red>
<%= exception.toString() %>
</font>
</h2>
</body>
</html>
-----------------------------------

The errorhandler.jsp is displayed alright and when the errorpage is expected, i get the HTTP 500 Internal server error page.
 
Have you set your web.xml properly ? Eg :

Code:
<web-app>
  <error-page>
    <error-code>500</error-code>
    <location>/errorhandler.jsp</location>
  </error-page>
...
<web-app>

--------------------------------------------------
Free Database Connection Pooling Software
 
Hi,

I am totally lost now. In the Tomcat JSP examples, all i see is that there are only JSPC servlet mappings. And in these too, the error page example doesn't work. All i have in my test project is 2 simple JSP files. Do i need to configure web.xml ?

I guess need a simple JSP-ONLY on Tomcat 5.0 tutorial. Any clue ?

thanks !
soumya.
 
If you set your web.xml to include the above (without the "..."), then it will work ...

--------------------------------------------------
Free Database Connection Pooling Software
 
Hi,

thanks for the replies. But it doesn't work in my system. I must be missing something really.

Here is the dir. structure of my JSP.

tomcat_home\webapps\error\errorhandler.jsp
tomcat_home\webapps\error\errorpage.jsp

Now i have placed a web.xml with only the entries you suggested under tomcat_home\webapps\error\WEB-INF

It still doesn't work. I get the errorhandler.jsp right when i select the correct language, but when exception is thrown, only the system error page comes up.

I checked with a friend's system (remote) and it works fine on her (both on Tomcat and JRun). I am puzzled.

thanks again,
soumya.
 
Ooooooooooops !! I just tried the same on Netscape 6.2, it works perfect !
Let me check my IE settings.

thanks a tonne for listening.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top