Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User teijap's Avatar
    Join Date
    Mar 2003
    Location
    Helsinki, Finland
    Posts
    12
    hi,
    i have used "GET" and it works just fine with HttpURLConnection.
    make URL from server address, then cast the url.openConnection() to HttpURLConnection, then use that.

    Brs,
    teija

  2. #2
    Registered User yuychen's Avatar
    Join Date
    Mar 2003
    Posts
    4
    I wish to make my pjava applicaton send data to servlet using
    POST method. But when I compiled the applicaion, compiler said: "java.net.HttpURLConnection is abstract; cannot be instantiated". I wonder if I can use HttpURLConnection in Pjava app. If not, what other classes can I use to communicate with servlet.

    Part of my program:

    ...
    HttpURLConnection conn = null;
    InputStream in = null;
    OutputStream out = null;
    String sentStr = "Request data to servlet";
    String servletUrl = "http://127.0.0.1:8080/examples/servlet/MyServlet";
    conn = new HttpURLConnection(servletUrl);
    conn.setRequestMethod(POST);
    out = conn.openOutputStream();
    int requestLength = sentStr.length();
    for (int i = 0; i < requestLength; ++i)
    {
    out.write(sentStr.charAt(i));
    }
    ...

    Thank a lot for any advises!

    Brs,
    Yuye Chen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved