Tutorial of calling jsp/servlet from android

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Tutorial of calling jsp/servlet from android

Postby maulik » Mon May 05, 2008 11:31 pm

Hi Moderator,

Currently I am building an application on android to run on tomcat apache and mysql as backend. I have followed some J2me tut to follow the concept but I am struct at the point where I create HttpURLConnection. Here is the code snippet I m writing.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private void invokeServlet(URL url) {
  2.  
  3.         // TODO Auto-generated method stub
  4.  
  5.                
  6.  
  7.         final HttpURLConnection hc =null;
  8.  
  9.         hc = new HttpURLConnection(url); // Here it doesnt allow me to call constructor of HttpURLConnection   
  10.  
  11.         InputStream is = null;
  12.  
  13.         OutputStream os = null;
  14.  
  15.         StringBuffer b = new StringBuffer();
  16.  
  17.  
  18.  
  19.         try {
  20.  
  21.                 hc.connect();
  22.  
  23.         }catch(Exception e) {
  24.  
  25.                 e.printStackTrace();
  26.  
  27.         }
  28.  
  29. }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

I will appreciate ur help/suggestions
maulik
Once Poster
Once Poster
 
Posts: 1
Joined: Mon May 05, 2008 11:24 pm

Top

Postby Steel » Tue May 06, 2008 12:16 am

I just do this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.              URLConnection conn = url.openConnection();
  2.  
  3.             conn.setDoOutput(true);
  4.  
  5.             conn.connect();
  6.  
  7.             OutputStream os = conn.getOutputStream();
  8.  
  9.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
Steel
Developer
Developer
 
Posts: 48
Joined: Fri Dec 28, 2007 1:11 pm
Location: Herning, Denmark

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 2 guests