Posting to web app and reading result

Discussion in 'ASP .Net' started by Stanley Beamish, Aug 21, 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 21, 2005
    #1
    1. Advertising

  2. Stanley Beamish

    Joerg Jooss Guest

    Stanley Beamish wrote:

    > 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:


    ASP? Then you're wrong here.

    ASP.NET? See System.Net.WebClient, which is an easy to use wrapper for
    the lower level HttpWebRequest/HttpWebResponse classes.

    Cheers,
    --
    http://www.joergjooss.de
    mailto:
     
    Joerg Jooss, Aug 21, 2005
    #2
    1. Advertising

  3. Stanley Beamish

    Mark Rae Guest

    "Stanley Beamish" <> wrote in message
    news:KQYNe.9452$...

    > I was wondering how I could do the same in ASP.


    You could start by posting your question in the correct newsgroup:
    microsoft.public.inetserver.asp.general

    This newsgroup is for ASP.NET
     
    Mark Rae, Aug 21, 2005
    #3
    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:
    553
    alanb
    Apr 23, 2004
  2. Ghafran Abbas
    Replies:
    0
    Views:
    470
    Ghafran Abbas
    Oct 12, 2004
  3. someone12345
    Replies:
    3
    Views:
    442
    Roedy Green
    Sep 1, 2007
  4. Stanley Beamish

    Posting to web app and reading result

    Stanley Beamish, Aug 22, 2005, in forum: ASP General
    Replies:
    0
    Views:
    116
    Stanley Beamish
    Aug 22, 2005
  5. Michael Tan
    Replies:
    32
    Views:
    1,021
    Ara.T.Howard
    Jul 21, 2005
Loading...

Share This Page