wood burning stoves 2.0*
The moose likes Servlets and the fly likes response.sendError() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "response.sendError()" Watch "response.sendError()" New topic
Author

response.sendError()

Praveen Dharmavaram
Ranch Hand

Joined: Nov 05, 2002
Posts: 59
Hi,
This question might have been asked before, excuse me for asking it again.
I was sending an error code and an error message using the following code in my servlet under WAS(3.5.7)
****************************
int errCode = 7000;
String errMsg = "Testing Error Message";
response.sendError(errCode, errMsg);
****************************
and in my JSP code i do the following
**************************************
<%@ page import="com.ibm.webspherre.servlet.error.*" %>
<%
ServletErrorReport error = (ServletErrorReport) request.getAttribute(ServletErrorReport.ATTRIBUTE_NAME);
String errorCode = error.getErrorCode();
String errorMsg = error.getMessage();
%>
*****************************************
All the above code used to work fine. I recently upgraded the whole application to WAS5.0(J2EE 1.3), and every thing stopped working. I wonder if I am using the wrong WebSphere package or is there some thing wrong i am doing in my code. In other words, Can i pass my own error code or do i need to use the standard error codes. The next part of the question is is there an alternate way of doing it?
Thanks
Praveen
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
well what are the errors you get? this might be better in the websphere forum too?


Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
Praveen Dharmavaram
Ranch Hand

Joined: Nov 05, 2002
Posts: 59
Even though i pass an error code of 7000. All i see on that page is 500. The message comes out fine and I see the following in the console window
[11/21/03 10:03:52:672 EST] 2e648371 WebGroup E SRVE0026E: [Servlet Error]-[TestError]: com.ibm.ws.webcontainer.webapp.WebAppErrorReport: Testing Error Condition
at com.ibm.ws.webcontainer.srt.SRTServletResponseContext.sendError(SRTServletResponseContext.java:152)
at com.ibm.ws.webcontainer.srt.SRTServletResponse.sendError(SRTServletResponse.java:626)
at com.ibm.annap.test.TestError.doPost(TestError.java:26)
at com.ibm.annap.test.TestError.doGet(TestError.java:19)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
Praveen Dharmavaram
Ranch Hand

Joined: Nov 05, 2002
Posts: 59
Actually the message i was sending was "Testing Error Condition" and not "Testing Error Message".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: response.sendError()
 
Similar Threads
Problems getting a JSP to act as proxy
Erro using HttpServletResponse.
Error Message.
Error Message.
No Property Error