Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
Sunilkumar
Posts: 75
Registered: 07-21-2009

Http Connection problem

Hi all,

         I am not ablt to connect to server below is my code

 public void IssueHTTPPostL(String name) throws IOException
	  {
		  synchronized(this)
          {  
	    HttpConnection httpConn = null;	 
	    String url = "http://200.196.100.21:8100/test/dbget.jsp;deviceside=true;apn=blackberry.net;";
	    InputStream is = null;
	     InputStream is1 = null;
	    OutputStream os = null;

	    try {
	      
	      httpConn = (HttpConnection)Connector.open(url);        //after this line code is not going to execute(i have done debug......)
	      // Setup HTTP Request to POST
	      httpConn.setRequestMethod(HttpConnection.POST);

	      httpConn.setRequestProperty("Accept_Language","en-US");
	      //Content-Type is must to pass parameters in POST Request
	      httpConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

	      httpConn.setRequestProperty("imei", "1243242434");
	      httpConn.setRequestProperty("user", "xxx");
	    //  httpConn.setRequestProperty("name", "abcd");
			httpConn.setRequestProperty("password", "dmw");
//	      httpConn.setRequestProperty("contentType", "Images");
//	      httpConn.setRequestProperty("task", "retrieve");





	      os = httpConn.openOutputStream();

	      String params;
	      params = "name=" + name;

	      os.write(params.getBytes());

	     

	      // Read Response from the Server

	      StringBuffer sb = new StringBuffer();
	      is = httpConn.openDataInputStream();
	      int chr;
	      while ((chr = is.read()) != -1)
	        sb.append((char) chr);

	        System.out.println(sb.toString());


	int i = httpConn.getResponseCode();
	if (i == HttpConnection.HTTP_OK)
	{
		
		System.out.print("HTTP_OK");
	}
	
	//form.append(""+i);
	                  
	//form.append(sb.toString());
	//form.append(httpConn.getRequestProperty("name"));
	      } finally {
	        if(is!= null)
	           is.close();
	          if(os != null)
	            os.close();
	      if(httpConn != null)
	            httpConn.close();
	    }

	    }
	  }

 

 

Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: 07-15-2008

Re: Http Connection problem

Are you sure about the APN which you set in the URL is correct respect to the network operator?


Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.
Developer
Sunilkumar
Posts: 75
Registered: 07-21-2009

Re: Http Connection problem

hi,

 thanks for your reply. yes airtel india.it is correct.

Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: 07-15-2008

Re: Http Connection problem

What exception is thrown?


Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.
Developer
Sunilkumar
Posts: 75
Registered: 07-21-2009

Re: Http Connection problem

Hi,

       it throws IOexception.

thanks for reply once again.

 

 

Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: 07-15-2008

Re: Http Connection problem

Check this thread.

 

http://supportforums.blackberry.com/t5/Java-Development/http-connection/m-p/318494


Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.
Developer
Posts: 1,474
Registered: 04-14-2009

Re: Http Connection problem

I think the issue is caused by you using the wrong APN. Via the "blackberry.net" APN one can usually only access the RIM's network infrastructure -- it's not usually possible to get a direct IP route to the Internet via the "blackberry.net" APN.

Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: 07-15-2008

Re: Http Connection problem

Right klyubin.

 

@op - check the thread which I have posted, it has a APN for Airtel.

 


Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.
Developer
Sunilkumar
Posts: 75
Registered: 07-21-2009

Re: Http Connection problem

[ Edited ]

Hi,

     i m still getting ioxception even though i used airtelgprs.com forapn.i have just checked the funambol sync.it show the apn blackberry.net while connecting to their server.why am i getting ioexception.is it my code right ?

 

thanks,

sunil

Please use plain text.
New Developer
anto
Posts: 1
Registered: 06-23-2009

Re: Http Connection problem

Use airtelgprs.com for APN

Please use plain text.