How to detect servlet forwarding problem?

Hi all experts,

I have a servlet that forward (using forward method in request dispatcher) the requests to a certain destination URL.

But if that URL is down or not found (like 500 or 404), forward method will not throw exception.

But how do I get the response code in this forwarding? Interpret the response header from output stream of response object? I did not found any related methods in java that can simply allow us to get the response code (only allow us to set but not get).

Thanks a lot!

[529 byte] By [cflui6a] at [2007-10-2 14:27:16]
# 1
in the requestDispatcher.forward the parameters are request and response objects and it throws servelt exception and IOException if there is any problem.and the forward doesn't take URL as parameter.sendRedirect takes the URL as parameter.
sireesha2035a at 2007-7-13 12:47:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hello,I have tried to use request dispatcher forward method to do so but if the destination page returns 404, forward method did not throw any exception at all!
cflui6a at 2007-7-13 12:47:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

If you are using JBOSS or other application servers in that web.xml of your application just write

<error-page>

<error-code>404</error-code>

<location>Error.jsp</location>

</error-page>

then it will be taken care of by container

Innovaa at 2007-7-13 12:47:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...