problem in http connection ........

Put your problem here if it does not fit any of the other categories.

problem in http connection ........

Postby abhilash » Tue Feb 26, 2008 2:08 pm

hi pls check this wether this is right or not; ia m unhable to connect to server ........... pls help me....



Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. DataInputStream is;
  2.  
  3.         URLConnection con;
  4.  
  5.        String urlString = "http://192.168.157.35:8080/myown/Login.do";
  6.  
  7.        String username="abhi";
  8.  
  9.        URL url;
  10.  
  11.         try {
  12.  
  13.                 url = new URL(urlString);
  14.  
  15.                 con=url.openConnection();
  16.  
  17.                 if (con instanceof HttpURLConnection)
  18.  
  19.                 {
  20.  
  21.                 System.out.println("This is HttpURLConnection");
  22.  
  23.                 ((HttpURLConnection)con).setRequestMethod("POST");
  24.  
  25.                 con.setDoInput(true);
  26.  
  27.                 con.setDoOutput(true);
  28.  
  29.                 dos = new DataOutputStream(con.getOutputStream());
  30.  
  31.                 dos.writeUTF(username);
  32.  
  33.                 dos.close();
  34.  
  35.              
  36.  
  37.                         }
  38.  
  39.         }
  40.  
  41.         catch (IOException e) {
  42.  
  43.                        
  44.  
  45.         }
  46.  
  47.          }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
abhilash
Developer
Developer
 
Posts: 26
Joined: Fri Feb 22, 2008 11:21 am
Location: HYDERABAD

Top

Postby plusminus » Tue Feb 26, 2008 6:43 pm

Hello abhilash,

Have a look at this topic: :arrow: :src: http://www.anddev.org/viewtopic.php?t=492

It contains more than one ways of doing HTTP Post.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 21 guests