aspose file tools*
The moose likes JSP and the fly likes JSTL exception handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL exception handling" Watch "JSTL exception handling" New topic
Author

JSTL exception handling

Kelley Russon
Greenhorn

Joined: Jan 07, 2004
Posts: 3
I need to access JSP exceptions in a JSP error page, but I can't use Java in the JSP. Is there a way to display the exception text using JSTL?
Here's what works using embedded Java (code in the JSP error page):
<%out.println(exception);%><br>
Here's how I tried in JSTL, but it just doesn't return anything (code in the JSP error page):
<cut value="${exception}"/><br>
There's gotta be a way! Anyone have an idea? All the examples I can find use the embedded Java method.
[ January 07, 2004: Message edited by: Kelley Russon ]
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
but I can't use Java in the JSP
Can you explain why you can't use Java in the JSP? That will probably help us provide solutions that you can use.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Kelley Russon
Greenhorn

Joined: Jan 07, 2004
Posts: 3
I "can't" use Java in my JSP because it is our coding policy not to. Maybe "am stongly encouraged not to" would be better.
I was hoping that there would be a simple way of doing this using JSTL or EL. We are using JSP 2.0.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

You have declared the JSP as an error page, right?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Kelley Russon
Greenhorn

Joined: Jan 07, 2004
Posts: 3
Yes, it's defined as an error page with this line in the JSP that has the error:
<%@ page contentType="text/html; charset=iso-8859-1" errorPage="../jsp/error.jsp" %>
The embedded Java code works fine in my error page. I just want to replace it using EL.
Here's the entire error.jsp:
---------------------------------------
<%@ page isErrorPage="true" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
<body>
<% out.println("java >> " + exception + "<br>"); %>
cut >> <cut value="${exception}"/><br>
</body>
</html>
---------------------------------------
Here's the output when I have my JSP cause an exception:
---------------------------------------
java >> java.lang.NullPointerException
cut >>
---------------------------------------
So the exception value is there, I just want to access it with cut instead of java, and all I get is nothing.
I think I'm realizing that maybe I should just let it go... but if someone has any idea how to do this, that would be great!
[ January 08, 2004: Message edited by: Kelley Russon ]
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Can you tell us which server you are using? If you are using Tomcat 5, try it on Resin 3 so we can be sure that this isn't just an implementation bug.
It sure sounds as if it ought to work.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL exception handling
 
Similar Threads
app error page - no exception details.
pageContext.exception is not executing
sending/retrieving data via SQL statements...
Exception: c:catch doubt
About catching error