Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

HttpConnection returns null

 
Greenhorn
Posts: 15
  • 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
 
Bartender
Posts: 9612
16
Mac OS X Linux Windows
  • 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
  • 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: 9612
16
Mac OS X Linux Windows
  • 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.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic