The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Here it is...

Posted by Kishori Sharan on April 22, 2001 at 3:28 AM

Hi
You can use URL and URLConnection for this purpose. Just replace the url and query string in this code with yours and it will work. It also reads the output from the URL and displays it on console.
Thanx
Kishori
///////// T1.java

import java.net.* ;
import java.io.* ;

class T1 {

public static void main ( String[] args ) throws Exception{

String urlStr = "http://localhost:8080/kishori/velu.jsp" ;
String queryStr = "q=hello" ;
URL url = new URL ( urlStr + "?" + queryStr );
URLConnection con = url.openConnection ( ) ;

InputStream in = con.getInputStream() ;

int c ;

while (( c = in.read ( ) ) != -1 )
System.out.print ( (char)c ) ;


}
}



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us