Or something bean-based might work. Not sure if it's any better than writing a tag.
ExceptionBean.java:
-------------------
package foo;
import java.io.*;
public class ExceptionBean implements Serializable {
private Throwable t;
public Throwable getThrowable() { return this.t; }
public void setThrowable(Throwable t) { this.t = t; }
public String toString() {
if (this.t == null) {
return "throwable is null";
} else {
CharArrayWriter chars = new CharArrayWriter();
PrintWriter out = new PrintWriter(chars);
t.printStackTrace(out);
return chars.toString();
}
}
}
stackTrace.jspf:
----------------
<c:set var="throwable"
value="${requestScope['javax.servlet.error.exception']}"/>
<jsp:useBean id="exceptionBean"
class="foo.ExceptionBean"/>
<c:set target="${exceptionBean}"
property="throwable"
value="${throwable}"/>
<c:out value="${exceptionBean}"/>
whatever.jsp:
-------------
<%@ include file="stackTrace.jspf" %>
Quoting "Chen, Gin" <[EMAIL PROTECTED]>:
> There is currently no way to do that using JSP 1.x because it will not
> allow
> method calling (including passing parameters) using EL.
> However, this will change in JSP 2 as this will be supported.
> So for now I guess your stuck with using a scriptlet or creating a simple
> tag to do this.
> -Tim
>
>
> -----Original Message-----
> From: Martin van Dijken [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, July 16, 2003 10:27 AM
> To: Tag Libraries Users List
> Subject: RE: Exception var - how to get using JSTL
>
>
> Erm,
>
> Not really experienced enough with JSTL yet for that. What you're currently
> getting is the exception.toString(). For the full stacktrace you'd need to
> do:
>
> <%
> ((Exception)request.getAttribute("javax.servlet.error.exception")).printStac
> kTrace(response.getWriter());
> %>
>
> How to express that in JSTL, I don't know. I'd specifically not know
> whether
> the cast was necessary and how to pass the printStackTrace method the
> PrintWriter.
>
> Martin
>
> > -----Original Message-----
> > From: Jeff Born [mailto:[EMAIL PROTECTED]
> > Sent: woensdag 16 juli 2003 16:24
> > To: Tag Libraries Users List
> > Subject: RE: Exception var - how to get using JSTL
> >
> >
> > Martin,
> >
> > That worked, but I only see the first line of the stacktrace.
> > Anyway to get
> > the entire stacktrace?
> >
> > This is what I currently have:
> >
> > <c:out value="${requestScope['javax.servlet.error.exception']}" />
> >
> > Thanks,
> >
> > jb
> >
> > -----Original Message-----
> > From: Martin van Dijken [mailto:[EMAIL PROTECTED]
> > Sent: Wed 7/16/2003 10:07 AM
> > To: Tag Libraries Users List
> > Cc:
> > Subject: RE: Exception var - how to get using JSTL
> >
> >
> >
> > Hey Jeff,
> >
> > The exception is available as a parameter in the
> > request attributes
> > under "javax.servlet.error.exception".
> >
> > Martin
> >
> > > -----Original Message-----
> > > From: Jeff Born [mailto:[EMAIL PROTECTED]
> > > Sent: woensdag 16 juli 2003 16:08
> > > To: Tag Libraries Users List
> > > Subject: RE: Exception var - how to get using JSTL
> > >
> > >
> > > I would like to have an error page that handles exceptions
> > > that flows the
> > > site I'm developing. In order to do this I would like to
> > > replace the Tomcat
> > > generated page with a jsp:
> > >
> > >
> > >
> > > <error-page>
> > >
> > > <exception-type>java.lang.Throwable</exception-type>
> > >
> > > <location>/jsp/error.jsp</location>
> > >
> > > </error-page>
> > >
> > >
> > >
> > > Then in the error.jsp have a line like :
> > >
> > >
> > >
> > > <c:out value="${pageContext.exception.stacktrace}" />
> > >
> > >
> > >
> > > However nothing prints. If I modify the jsp containing the
> > > preceding c:out
> > > to contain an error, then the Tomcat Error page takes over and
> > shows a
> > > stacktrace. So I know one is available, I just need to know
> > > how to access
> > > it! Anyone know what I’m doing wrong?
> > >
> > >
> > >
> > > Thanks,
> > >
> > >
> > >
> > > jb
> > >
> > > -----Original Message-----
> > > From: Michael Duffy [mailto:[EMAIL PROTECTED]
> > > Sent: Wed 6/18/2003 7:47 AM
> > > To: Tag Libraries Users List; Jim Kennedy
> > > Cc:
> > > Subject: Re: Exception var - how to get using JSTL
> > >
> > >
> > >
> > >
> > > Yes, 'javax.servlet.jsp.jspException' is the parameter
> > > name that's used when the exception value is set.
> > > It's important to know, because if you do MVC-2 with
> > > your own front controller servlet you've got to set
> > > that parameter inside the servlet whenever an
> > > exception is thrown. If you don't, the JSP error page
> > > won't find it.
> > >
> > > Buy Shawn Bayern's "JSTL In Action" book by Manning.
> > > What you wanted was right there on page 267. Lots of
> > > other good stuff, too.
> > >
> > > Anytime I'm faced with a new technology I like to have
> > > a good book at my elbow. When I started with JSTL,
> > > this was the only book I bought.
> > >
> > > --- Jim Kennedy <[EMAIL PROTECTED]> wrote:
> > > > This also works:
> > > > <c:set var="error"
> > > >
> > >
> > value="${requestScope['javax.servlet.jsp.jspException']}"
> > > > /> (for Tomcat)
> > > >
> > > > but I wanted to avoid the "javax.servlet.jsp..."
> > > > stuff.
> > > >
> > > > Your method is what I was looking for. I have not
> > > > read anything that lead
> > > > me to "exception" being the name of that property.
> > > > Is there a table that
> > > > shows all available pageContext properties. It's
> > > > definitely logical though
> > > > since exception is an implicit variable for JSP
> > > > pages. However, that
> > > > pattern breaks down for:
> > > >
> > > > pageContext.servletConfig which is "config" in JSP
> > > > pages
> > > >
> > > > and
> > > >
> > > > pageContext.servletContext which is "application" in
> > > > JSP pages.
> > > >
> > > > Can you tell me how you came by this info for
> > > > "exception".
> > > >
> > > >
> > > >
> > > > thanks
> > > >
> > > >
> > > > Jim Kennedy
> > > > IT Consultant
> > > > Mobile Phone: 813-503-1484
> > > >
> > > -----------------------------------------------------
> > > >
> > > >
> > > >
> > > > ----- Original Message -----
> > > > From: "Michael Duffy" <[EMAIL PROTECTED]>
> > > > To: "Tag Libraries Users List"
> > > > <[EMAIL PROTECTED]>; "Jim
> > > > Kennedy" <[EMAIL PROTECTED]>
> > > > Sent: Tuesday, June 17, 2003 4:39 PM
> > > > Subject: Re: Exception var - how to get using JSTL
> > > >
> > > >
> > > > >
> > > > > Wouldn't you use
> > > > >
> > > > > <c:out value="${pageContext.exception.message}"/>?
> > > > >
> > > > > That's just straight JSTL, so it should be okay. -
> > > > MOD
> > > > >
> > > > >
> > > > >
> > > > > --- Jim Kennedy <[EMAIL PROTECTED]> wrote:
> > > > > > Can someone help me with the technique to grap
> > > > the
> > > > > > exception (implicit)
> > > > > > variable that exists when isErrorPage=true. I
> > > > know
> > > > > > it will be part of the
> > > > > > pageScope JSTL variable, but I need a technique
> > > > NOT
> > > > > > specific to a container.
> > > > > >
> > > > > > I don't want to use <% %> at all. I need an
> > > > only
> > > > > > tag technique.
> > > > > >
> > > > > > Currently there is not ${exception} guy.
> > > > > >
> > > > > > Thanks
--
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech <http://www.dotech.com/>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]