Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > HTTPConnection - verbose error messages

Thread Tools

HTTPConnection - verbose error messages

Posts: n/a
I have a java application that polls an asp page for the purpose of
inserting to a data base. I am interested in getting verbose (ie
unfriendly HTTP error messages) when there is an internal server error
(code 500). Below is the code snippet that makes the application's web
connection and captures the response messages.

String user = "";
//String user = "Someone";

try{//create url object
urlWithQueryString =
"" + user +
"&FName=Alonzo&LName=Garbonzo&timeStamp=20060110_1 106";
System.err.println("urlWithQueryString ln 35: " +
url = new URL(urlWithQueryString);
}catch(MalformedURLException mURLE){
System.err.println( "MalformedURLException thrown in WriteToWebDB: ln
41 " + mURLE.getMessage() );

try{//open connection. Write data succeeds or fails here
connection = (HttpURLConnection)url.openConnection();
inputStream = connection.getInputStream();
}catch(IOException iOE1){
System.err.println( "IOException caught in WriteToWebDB: ln 52");
System.err.println("Connection response code ln 53: " +
System.err.println("Connection message ln 54: " +
System.err.println("Exception message ln 55: " + iOE1.getMessage());
}catch(IOException iOE){System.err.println("IOException caught ln 56"
+ iOE.getMessage());}


Below are three examples of server output - two have defective
connection strings to force server error and one is a good connection
string that inserts to the data base. Note that the defective string
passed from the application returns an error message without much
information while the defective string passed from a browser returns a
verbose and detailed error message. Can anyone help in discovering a
way to recover verbose detailed error messages in the java application?
Any help is greatly appreciated.

Guy Sussman


Web server output to application connection when String user = ""

urlWithQueryString ln 35:
IOException caught in WriteToWebDB: ln 52
Connection response code ln 53: 500
Connection message ln 54: Internal Server Error
Exception message ln 55: Server returned HTTP response code: 500 for


Web server output to browser connection when String user = ""

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] Field 'tbl_test.Usr' cannot
be a zero-length string.
/lpt/lpt_login.asp, line 25


Web server output to application connection when String user =

urlWithQueryString ln 35:
Http connection status (WriteToWebDB ln.69): OK ResponseCode = 200


Reply With Quote
Posts: n/a

Reply With Quote
Andrea Desole
Posts: n/a
guyzdancin wrote:
> Hello

If I'm not wrong you should call the getErrorStream() method of
HttpURLConnection. This is used in case of error messages
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
midlet error when using httpconnection in netbeans Orson Java 5 08-26-2008 09:58 AM
HTTPConnection - verbose error messages guyzdancin Java 0 01-11-2006 08:08 PM
J2ME, HttpConnection and Proxy Marko Java 11 10-19-2004 11:13 AM
vbc vommand line compiler verbose messages Sam ASP .Net 2 12-02-2003 09:54 PM
HTTPConnection through proxy Molz Java 3 09-19-2003 12:01 PM