Pat,
Do something like this on the JSP side:
<%@ page import="java.util.*" %>
<%@ page import="javax.servlet.http.*" %>
<SCRIPT RUNAT="server">
private String getSearchResults( HttpServletRequest request,
HttpServletResponse response,
String passedQueryString,
String targetURL )
throws java.io.IOException
{
StringBuffer retBuffer = new StringBuffer();
try{
retBuffer.append(
GeneralPubXSearchEngine.getEngineResults( request,
response,
passedQueryString,
targetURL )
);
}catch( Exception error ){
ErrorHandler.log("In JSP page generalsearchresults.jsp:",
error);
response.sendRedirect("/error/server_error.html");(Important
define your error page)
}
return retBuffer.toString();
}
</SCRIPT>
Have a error page defined on the server and the same html page can be used
for displaying servlet errors as well as errors on a JSP page.
Servlet side code sample
public static String getEngineResults( HttpServletRequest req,
HttpServletResponse res,
String passedQueryString,
String targetURL )
throws ServletException, IOException
try { BLOCK !!!!!!!!!!!!!!!!!!!!!!!!!
} catch (Exception e) {
ErrorHandler.log("In JSP page genpubxsearchres.jsp:", e);
res.sendRedirect("/error/server_error.html");
}
return outBuffer.toString();
}
Hope this helps.
-----Original Message-----
From: Patrick Buchanan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 09, 2000 9:11 AM
To: [EMAIL PROTECTED]
Subject: JSP Error Page with a servlet
I sent this out yesterday without a single reply. Can anyone help me on
this?
I'm new at Java so any advice would be appreciated.
How do I use a JSP Error Page with a servlet? I assume I use a
RequestDispatcher object to forward the request and response objects to the
JSP,
but does anyone have a code example of how to accomplish this? Do I have to
store it as a request attribute and then have code in the JSP to pull it out
and
print it to the screen? What is the easiest way here?
I want to use the same JSP error page for both my controller servlet and the
associated JSP's.
pat
"This may contain information that is confidential or privileged. If you are
not
the addressee indicated in this message (or responsible for delivery of this
message to such person), you should not copy or deliver this message to
anyone or make any other use of the information set forth herein. In such
case, you should destroy this message and notify the sender by telephone
or e-mail."
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
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
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
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