Hi guys,


I have a servlet(Servlet1) which should open URLConnection to another servlet(Servlet2) and read the response from Servlet2.

I did the following but i got null response. please please help me

URL parURL = new URL("Another Servlet URL");
HttpURLConnection urlConnection =
(HttpURLConnection) parURL.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);

urlConnection.setRequestProperty("Content-type", "application/x-www-form-urlenCcoded");
urlConnection.setAllowUserInteraction(true);

urlConnection.connect();
System.out.println("1");
StringBuffer sb = new StringBuffer();
InputStream in=null;;
try {
in =
((HttpURLConnection) urlConnection).getInputStream();
} catch (Exception ex) {
System.out.println("Exception:"+ex.getStackTrace() );
}
int length = urlConnection.getContentLength();
System.out.println("2");
for (int n = 0; n < length; n++) {
sb.append((char) in.read());
}
System.out.println("String Buffer Content:"+sb.toString());



Please help me ASAP ...

Thanks
Sudarshan