File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpConnection returns null

 
lekkie Nakel
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was trying to open a page and read from the stream.

Actually, the page returns different type os response. When a transactionis succesful it returns 200 if the transaction has some problems it sends dsome other response code (other than 200).

I want to be able to read the stream (content of the stream) even though the response code is not 200. I discovered if I open the url with the URL library or, once the response code is not 200, it closes the stream, hence any attempt to read it throws exception

However, I tried opening the stream from with httpconnection
HttpConnection conn = (HttpConnection)
Connector.open(req,Connector.READ,true);

but conn returns null.

why is that.

I am behind a proxy, so I set the system property:
System.setProperty("http.proxyHost","172.16.10.2");
System.setProperty("http.proxyPort","8080");

before calling connector.open

Thnx
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this really your code:

or are you giving us some red herrings? There's no Connector class in the J2SE and HttpConnection doesn't have an open method. I suggest you tell the details because the better question you ask, the better answer we can give.
 
lekkie Nakel
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, my err.

But HttpConnection can only b found in j2me. So am talkin abt j2me httpconection (it is only httpURLconnection that is in j2se)

I was wondering if I can retrieve the message that is sent when an httpURL connection returns a response codes other than 200?

I know it throws an ioe exception when a response other than 200 is returned, is there a way to retrieve the message returned by a servlet with response code 401?

If I cant get the message, what other method can I use connect to a server and still open the stream after it has thrown the err?
[ February 14, 2007: Message edited by: lekkie Nakel ]
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, you aren't giving us the whole story. Which J2ME API are you using? There are several.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic