When I connect to my servlet using either HttpURLConnection (J2SE) or
HttpConnection (J2ME), there are times when I want to send back to the
client something other than HttpServletResponse.SC_OK. In J2ME, it
seems to handle non-SC_OK responses okay, but in J2SE it consistently
throws an IOException when the response comes back. Is there a way, in
J2SE, to receive a non-SC_OK response without having an exception
thrown? My servlet code is as follows:
// servlet code
public void doPost(HttpServletRequest request,HttpServletResponse
response)
throws ServletException, IOException
{
// if an error condition occurs, a class throws a
ProxyCommandException
catch(ProxyCommandException error)
{
response.sendError(error.getStatusCode(),error.getMessage());
}
}
// J2SE client code
public void sendCommand(ProxyCommand command)
throws IOException
{
// HttpURLConnection is established
/* the command's been sent, getting the response code
this line, whenever it's not SC_OK, *always* throws
an exception */
int rc = connection.getResponseCode();
// code to handle the value of rc
}
What can I do to fix this?
--
Darryl L. Pierce <[EMAIL PROTECTED]>
Visit the Infobahn Offramp @ <http://welcome.to/mcpierce>
"What do you care what other people think, Mr. Feynman?"
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html