Hi all,

I am having a bit of a problem trying to get the exception thrown in a JSP
page that is being read in via code (instead of forwarded or redirected to).
I am doing this to use JSP to spit out dynamic XML (instead of HTML). I know
there are some taglibs that allow parts of a JSP page to be used in this
fashion. I want to use the whole page. So I do this:

try
{
  StringBuffer link = new StringBuffer();
  link.append( request.getScheme() + "://localhost" + r.getName() );
  if( r.getName().indexOf("?") >= 0 )
    link.append("&jsessionid=" + request.getSession(true).getId() );
  else
    link.append("?jsessionid=" + request.getSession(true).getId() );

  URL url = new URL(link.toString());

  xmlStream = new StreamSource(url.openConnection().getInputStream());
}
catch(Exception e)
{
  System.out.println(e.getMessage());
  e.printStackTrace(System.out);
}



If anyone has better code to read in JSP for its dynamic output, I am all
ears (or eyes). The problem is, if you have a JSP page like this:

<%
  Object o = null;
  System.out.println(o.toString());
%>

<my-tag>
</my-tag>


The JSP page will "break" at run-time, throwing a Null Pointer Exception.
But, in the catch block, where it prints both the error message and the
stack trace, you don't see the same error message you would see in the
browser if you had just forwarded to that JSP page. The error should spit
out some sort of Null Pointer Exception message. But the error I get, no
matter what error the JSP page generates (both compile time and run time),
is always a File Not Found exception..meaning it was not able to "open" the
JSP page and read its contents in.

So, how would I get the JSP error message it sends to the output (or catch
it) to redisplay it?

Thanks.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to