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
Regular Contributor
Posts: 50
Registered: ‎01-05-2011
My Device: 9300
My Carrier: Engineer

HttpConnection returning status code 302

Hi,

     I am connecting to my Tomcat sever. My system has public ip. So i can access any web appliction remotely. I am connecting to my web server from my application using 

HttpConnection.

 

 

 

 public class Test_main extends UiApplication { 

 

 

 

public static EditField _logField;

 

public MainScreen _mainScreen;

 

HttpConnection conn ;

 

public static void main(String[] args)

 

{

 

 

  Test_main app = new Test_main();

 

  app.enterEventDispatcher();

 

}

 

public Test_main()

 

{

 

    _mainScreen = new MainScreen();

 

   _logField = new EditField("Log:", "");

 

   _mainScreen.add(_logField);

 

   pushScreen(_mainScreen);

 

  try

   {

 

     conn =( HttpConnection)Connector.open  (http://my ip/myapp/index.html);

 

  conn.setRequestMethod("GET");

 

 _logField.setText(_logField.getText() + "\n  Response is" +    conn.getResponseCode());

 

}

 

catch (Exception e) {

 

     // TODO: handle exception

 

}

 

 

}

 

 

 

}

 

It is returning Response 302.Using browser i can connect to the above

link (i.e http://my ip/myapp/index.html). I am using Blackberry model 9300, O.S  5.0.

Please help me.

 

Thank you

--------------------

P.Ramkumar.

 

 

 

 

Developer
Posts: 163
Registered: ‎07-16-2008
My Device: Not Specified
My Carrier: Sprint

Re: HttpConnection returning status code 302

A response code 302 indicates a redirect - your browser will automatically handle it, but you would need to handle it manually in your application.

 

The "Location" header of the response should indicate where it is trying to redirect you - you would just make another HttpConnection to that location.

Andrew Cowart | Metova
www.metova.com
Developer
Posts: 19,623
Registered: ‎07-14-2008
My Device: Not Specified

Re: HttpConnection returning status code 302

Developer
Posts: 16,643
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: HttpConnection returning status code 302

and if you are looking at peters sample anyhow you can use it to move your connection handling out of the event thread.

http://supportforums.blackberry.com/t5/Java-Development/What-is-the-Event-Thread/ta-p/446865

----------------------------------------------------------
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