Posting to web app and reading result

Discussion in 'ASP General' started by Stanley Beamish, Aug 22, 2005.

  1. Hello I'm an ASP newbie needing to translate a JAVA program into ASP. I
    have a servlet that posts data to another servlet and reads back the
    response. I was wondering how I could do the same in ASP. The bits of Java
    code are:

    HttpURLConnection conn = null;
    try
    {
    URL url = new URL(urlStr);
    System.out.println("Opening connection to: " + urlStr);
    conn = (HttpURLConnection)url.openConnection();
    conn.setDoOutput(true);

    System.out.println("Sending data to url");
    PrintWriter out = new PrintWriter(conn.getOutputStream());
    out.println(text);
    out.close();

    System.out.println("Reading response.");
    BufferedReader in = new BufferedReader(
    new InputStreamReader(conn.getInputStream()));
    String inputLine;
    StringBuffer sb = new StringBuffer();

    while ((inputLine = in.readLine()) != null)
    {
    sb.append(inputLine);
    }

    in.close();
    System.out.println(sb.toString());
    } catch (Exception e)
    {
    System.out.println(e.getMessage());
    }

    Any pointers greatly appreciated.

    SB
     
    Stanley Beamish, Aug 22, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. alanb
    Replies:
    2
    Views:
    575
    alanb
    Apr 23, 2004
  2. Ghafran Abbas
    Replies:
    0
    Views:
    477
    Ghafran Abbas
    Oct 12, 2004
  3. Stanley Beamish

    Posting to web app and reading result

    Stanley Beamish, Aug 21, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    386
    Mark Rae
    Aug 21, 2005
  4. someone12345
    Replies:
    3
    Views:
    449
    Roedy Green
    Sep 1, 2007
  5. Michael Tan
    Replies:
    32
    Views:
    1,073
    Ara.T.Howard
    Jul 21, 2005
Loading...

Share This Page