I am using weblogic server 8.1 sp5.
I have a servlet that generates an error code and returns a "message" as a text.
The problem is that iam not getting the "message" returned on my http protocol layer.
BUT when i use "setStatus" method instead of "sendError" method, everything works fine. setStatus is deprecated and we are told not to use it.
NOTE: When i run the servlet with sendError method, it works fine on the browser BUT it is not returned in my http (at the protocol layer).
Can somebody shed some light on the difference of this behavior?
Attached is the code.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class MyWebServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("This is MyWebServlet");
String message= "Testing custom message of a 592 Error"
response.sendError(592,message);
out.close();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
}