• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSTL exception handling

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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):
<c:out 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 ]
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>"); %>
c:out >> <c:out value="${exception}"/><br>
</body>
</html>
---------------------------------------
Here's the output when I have my JSP cause an exception:
---------------------------------------
java >> java.lang.NullPointerException
c:out >>
---------------------------------------
So the exception value is there, I just want to access it with c:out 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: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic