Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL exception handling

 
Kelley Russon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kelley Russon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have declared the JSP as an error page, right?
 
Kelley Russon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic