BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 03-27-2008, 11:30 AM   #1
shailesh.astute
New Member
 
Join Date: Mar 2008
Model: 8820
PIN: N/A
Carrier: Airtel
Posts: 5
Default HttpConnection

Please Login to Remove!

Hi,
I am newby for Blackberry. I need some consultation from the experts.

I am using my standard midlet(which i use for Nokia, Motorola and other devices) for Blackberry phones and it is working perfectly. But when i try to connect to the server using HttpConnection it does not connect and throws exceptions. Do i have to add some other code / settings as well and is it possible develop client-server based application using standard midlet or not?

I have tried jar/jad, cod/alx files but still not connect to the server.

Kindly guide me.

Thanks in advance.
Shailesh
Offline  
Old 03-28-2008, 06:33 AM   #2
bdowling
Thumbs Must Hurt
 
Join Date: Jan 2007
Model: 8800
Carrier: Orange
Posts: 181
Default

You need to do your connections on a non-UI thread to allow the blackberry to prompt the user to allow/disallow the connection.

I've written a getWebData method that you can see at http://www.dowling.me.uk/blog/blackb...ebbitmapfield/
Offline  
Old 04-02-2008, 01:11 PM   #3
shailesh.astute
New Member
 
Join Date: Mar 2008
Model: 8820
PIN: N/A
Carrier: Airtel
Posts: 5
Default HttpConnection

Hi,
Thanks for your reply.
Actually I am using standard midlet code which i run on Motorola and Nokia devices.

Here is the sample of code which is running perfectly on emulator but displaying error on device and i am unable to eastablish the connection.

Please guide me.

Thanks
Shailesh

---------------
Code:


import java.io.InputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class TestMidlet extends MIDlet implements Runnable,CommandListener
{
private Thread thread;
Display display;
Form frm=new Form("Response");
Command cmd=new Command("Exit",Command.OK,0);
public void startApp ()
{
display=Display.getDisplay(this);
frm.addCommand(cmd);
frm.setCommandListener(this);
display.setCurrent(frm);
try
{
thread = new Thread (this);
thread.start ();
}
catch(Exception e)
{
System.out.println(">>> Exception Caught : " + e.toString ());
}
finally
{
System.out.println("-- startApp() : end -- ");
}
}


public void commandAction(Command c,Displayable d)
{
if(c==cmd){
this.notifyDestroyed();
}
}
public void pauseApp ()
{
}

public void destroyApp (boolean unconditional)
{
}
StringBuffer str=new StringBuffer();
public void run ()
{
try
{
HttpConnection con = (HttpConnection) Connector.open("http://www.google.com");
frm.append("Tryig to Connect..");
InputStream is = con.openInputStream();
frm.append("\n\nNow Connecting..");
int c = 0;
while ((c = is.read()) != -1)
{
str.append((char) c);
}
frm.append("\n\n Connected: "+str);
display.setCurrent(frm);
is.close();
con.close();
}
catch(Exception e)
{
frm.append("\n\nException :" + e.toString());
}
finally
{
System.out.println("-- run() : end -- ");
}
}

}
Offline  
Old 04-02-2008, 01:13 PM   #4
shailesh.astute
New Member
 
Join Date: Mar 2008
Model: 8820
PIN: N/A
Carrier: Airtel
Posts: 5
Default

Please Help.

Last edited by shailesh.astute; 04-02-2008 at 01:14 PM..
Offline  
Old 05-15-2008, 03:13 PM   #5
srikokulan
New Member
 
Join Date: May 2008
Model: 8130
PIN: N/A
Carrier: ROGERS
Posts: 1
Default same problem

Hi shailesh.astute!
Did u get any response for your Midlet issue. Can u post if you have answer
thank you
Kokulan
Offline  
Old 05-22-2008, 06:52 AM   #6
baran_khan
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
Default Start MDS

Quote:
Originally Posted by srikokulan View Post
Hi shailesh.astute!
Did u get any response for your Midlet issue. Can u post if you have answer
thank you
Kokulan
HI,
Please I guess if you are using JDE 4.2 then you have to download and install the "Blackberry Email Service Simulator" and start the MDS before you attempt to use the HTTP Connection.

IT comes along with JDE 4.3 . Please confirm if that is the issue..

Thanks
__________________
Smart People ask for Help!!!
Offline  
Old 05-26-2008, 01:13 AM   #7
satyam
Knows Where the Search Button Is
 
Join Date: Feb 2008
Model: 7200
PIN: N/A
Carrier: Airtel
Posts: 25
Default

Hi shailesh ,
if u r using airtel connection while making httpConnection append parameters to it as :
(HttpConnection)Connector.open(baseURL+";WAPGatewa yIP=202.056.231.117;WAPGatewayAPN=airtelgprs.com") ;

now base url can be anything like ur server URL or "www.google.com"

just try this thing and see if its working.

-satish
Offline  
Old 05-26-2008, 01:20 AM   #8
satyam
Knows Where the Search Button Is
 
Join Date: Feb 2008
Model: 7200
PIN: N/A
Carrier: Airtel
Posts: 25
Default

before that ..are u trying it on device or on the simulator?..if simulator then i think ur wil just have to make proxyEnabled varibale from config file of the MDS true and if on device then just try above method
Offline  
Closed Thread



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

Forum Jump


Blackberries Advertising Vinyl Banner Flag Sign Many Sizes Available USA picture

Blackberries Advertising Vinyl Banner Flag Sign Many Sizes Available USA

$174.84



Blackberry Advertising Banner Vinyl Mesh Sign Fruit Vegetable Berry Farm Fresh picture

Blackberry Advertising Banner Vinyl Mesh Sign Fruit Vegetable Berry Farm Fresh

$179.95



BLACKBERRY MEAD Advertising Vinyl Banner Flag Sign Many Sizes MEDIEVAL V2 picture

BLACKBERRY MEAD Advertising Vinyl Banner Flag Sign Many Sizes MEDIEVAL V2

$96.93



BLACKBERRY MEAD Advertising Vinyl Banner Flag Sign Many Sizes MEDIEVAL picture

BLACKBERRY MEAD Advertising Vinyl Banner Flag Sign Many Sizes MEDIEVAL

$118.19



BLACKBERRY MEAD Advertising Vinyl Banner Flag Sign Many Sizes MEDIEVAL V3 picture

BLACKBERRY MEAD Advertising Vinyl Banner Flag Sign Many Sizes MEDIEVAL V3

$174.84



Little Trees 67343 Blackberry Clove Hanging Air Freshener for Car/Home 144 Pack picture

Little Trees 67343 Blackberry Clove Hanging Air Freshener for Car/Home 144 Pack

$94.99







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.