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

JSTL exception handling

 
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):
<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: 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.
 
Marshal
Posts: 67425
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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>"); %>
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: 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.
 
Every plan is a little cooler if you have a blimp. And a tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic