Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
enil
Posts: 35
Registered: ‎11-26-2008
My Device: 8100

how can i show http response

i want to know

1) how can i make http request

2) and how to show it's respnse to screen

 

i use JDE 4.2 and simulator is 9530

 

help plz

Please use plain text.
Developer
simon_hain
Posts: 15,999
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: how can i show http response

take a look at the different http demo samples that ship with the JDE
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
New Developer
sasha
Posts: 4
Registered: ‎12-12-2008
My Device: Not Specified

Re: how can i show http response

1. Use HttpConnection. Remember to use it in the separate thread so your UI doesn't lock until server responds.

2. Depends on what you want to display. You can add elements to the screen (labels, lists, etc) and pass your data to them.

In addition to the samples, I would suggest you look through developer guide (both basic and advanced)  - that would give you better understanding how to put everything together.

Please use plain text.
New Developer
criccomini
Posts: 26
Registered: ‎12-03-2008
My Device: Not Specified

Re: how can i show http response

Check out http://www.riccomini.name/Topics/Mobile/BlackBerry/BlackBerryHTTPClient/

 

Code snippet of how to make an HTTP call. Also works with HTTPS.

BlackBerry/Mobile Enthusiast - http://www.riccomini.name
Please use plain text.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: how can i show http response

if by response, you mean the response headers and not content, try stuff like this,

 

HttpConnection m_hc;
   k=m_hc.getHeaderFieldKey(i);
   if (k==null) break; 
      k=k.toLowerCase();
   String v=m_hc.getHeaderField(i);

if ( k!=null) xx+=k+ " "+v+"\n\r";
   if (k.equalsIgnoreCase("something"))...

++i;

Please use plain text.
Developer
simon_hain
Posts: 15,999
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: how can i show http response

HttpConnection offers the method getResponseCode. Here is an example, stripped it down a bit:

conn = (HttpConnection) Connector.open(url);
// if connection requires login
if (conn.getResponseCode() == 401) {
//basicauthconn
} else if (conn.getResponseCode()==200{
//proceed
}
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.