Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Want my exceptions to be caught by errorPage JSP ?

 
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will throwing my own exceptions within scriplets be caught by the JSP specified by my errorPage attribute ?

<%@ page errorPage="error.jsp"%>
<%

throw (new IllegalArgumentException("parameter xxx required"));

%>
Thanks
Pho
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Custom exceptions can also be caught by error page.
regds
maha anna
 
Pho Tek
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to throw a simple exception and got the error:
Unable to compile class for JSPC:\jakarta-tomcat-3.2.1\work\localhost_8080%2Fjspadmin\_0002fcsr_0002fAccountBillto_0002ejspAccountBillto_jsp_0.java:229: Statement not reached. out.write("\r\n"); ^ 1 error
Note that I am doing this inside an include file. And the including file is specifying the errorPage.
e.g.

Thanks
Pho
[This message has been edited by Pho Tek (edited May 16, 2001).]
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect the error is more related to your coding logic than throwing exceptions. Somewhere in your code a "return" or "throw someException" is there which is in "definite execute" path. There are some code under those return/throw kind of statement which can not be reached. So the compiler throws this error.
Please post your code.
regds
maha anna
[This message has been edited by maha anna (edited May 16, 2001).]
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please find below some code on exception errorpage JSP.
Errorpage.jsp
--------------
<%@ page isErrorPage="true" %>
<html>
<body>
<h1>
Error Page
</h1>
<hr>
<h2>
Received the exception:<br>
<font color=red>
<%= exception.toString() %>
</font>
</h2>
</body>
</html>
Errorhandler.jsp
----------------
<%@ page errorPage="errorpage.jsp" %>
<html>
<body>
<form method=post action="errhandler.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>
May be this could help you.
 
Our first order of business must be this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic