Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

not getting inputStream back after posting the form

 
rkmydam
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need a help in getting inputStream back from webserver. I am running following code from iplanet portal server, and try to get data from JRUN Server, I am posting userid and password to jrun server, but i am not getting information back from the server.
If anyone can help on this, I really appreciate that.
Thanks
Following is the source code
HttpURLConnection memLoginCon = (HttpURLConnection)memLoginURL.openConnection();
memLoginCon.setDoInput(true);
memLoginCon.setUseCaches(false);
memLoginCon.setRequestMethod("POST");
memLoginCon.setDoOutput(true);
memLoginCon.setAllowUserInteraction(false);
memLoginCon.setRequestProperty("Content-type", "text/html");
memLoginCon.setRequestProperty("Set-cookie",CookieVal);
memLoginCon.setRequestProperty("Pragma","no-cache");
memLoginCon.setRequestProperty("Server","JRun Web Server/3.0");
memLoginCon.setRequestProperty("Cache-control","no-cache");
memLoginCon.setRequestProperty("Connection","Close");
memLoginCon.setRequestProperty("Vary","Accept-Encoding");

DataOutputStream dos = new DataOutputStream(memLoginCon.getOutputStream());
String result = "username=iplanet";
result+= "&";
result+= "password=iplanet34";
System.out.println("result="+result);
dos.writeBytes(result);
dos.close();
// Read the response from the server
BufferedReader memLoginRdr = new BufferedReader(new InputStreamReader(memLoginCon.getInputStream()));
String nextLine;
FileWriter memLoginWtr = new FileWriter(memLoginFile);
FileWriter headerWtr = new FileWriter(headerFile);
while((nextLine=memLoginRdr.readLine())!=null) {
System.out.println("I am inside the while loop");
memLoginWtr.write(nextLine);
memLoginWtr.write("\n");
}
memLoginWtr.flush();
memLoginWtr.close();
memLoginRdr.close();
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"rkmydam",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic