For Programmers: Free Programming Magazines  


Home > Archive > ASP > August 2005 > Posting to web app and reading result









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Posting to web app and reading result
Stanley Beamish

2005-08-22, 7:55 am

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


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com