The Artima Developer Community
Sponsored Link

Java Answers Forum
re-connecting the server with the received cookie value

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
sakthivel

Posts: 7
Nickname: sakthivel
Registered: Oct, 2002

re-connecting the server with the received cookie value Posted: Nov 8, 2002 5:41 AM
Reply to this message Reply
Advertisement
Dear ALL,
yea, i found it...the thing is "setFollowRedirects(false)" doesn't work for the java1.3.(the said method will only work with java1.2). so we have to use the "HttpURLConnection.setFollowRedirects(false);" before opening the httpurl itself...now it is giving the cookies as expected....I am very happy that, in future people won't feel this pain of finding, this said bug with java1.3.
fine...
but now the problem is "I cant able to find my servlet program(in the domino server), getting executed....hope the way, i call my servlet file from my client machine(after getting authenticated) is correct...."

This is my java program:
###################
import java.io.*;
import java.net.*;

public class authen
{
public static void main(String args[]) throws Exception
{
String cookie = "";
try
{
URL theurl = new URL("http://192.168.10.55:8001/names.nsf?login&username=sakthivel&passw ord=12345");
HttpURLConnection.setFollowRedirects(false);
HttpURLConnection hurl = (HttpURLConnection)(theurl.openConnection());
hurl.connect();

int ic=0;
String key="";
while (ic<=10)
{
key = hurl.getHeaderFieldKey (ic);
if(ic<=10)
{
String value = hurl.getHeaderField (ic++);
System.out.println(key + " - " + value);
}
}

cookie = hurl.getHeaderField ("set-cookie");
System.out.println("cookie is - " + cookie);
hurl.disconnect();
}
catch(Exception exp)
{
exp.printStackTrace();
}

try
{
HttpURLConnection.setFollowRedirects(tru e);
URL serverURL = new URL("http://192.168.10.55:8001/servlet/testing");
HttpURLConnection urlconnection= (HttpURLConnection)serverURL.openConnection();
urlconnection.setRequestProperty ("set-cookie",cookie);
urlconnection.setRequestMethod("POST");
urlconnection.set DoOutput(true);
urlconnection.setDoInput(true);
urlconnection.setUseCaches(false );
urlconnection.setDefaultUseCaches(false);
urlconnection.setAllowUserInteracti on(true);
urlconnection.setRequestProperty("Accept-Language","en-us");
urlconnec tion.setRequestProperty("Content-type","application/x-www-form-urlencoded");
url connection.setRequestProperty("User-Agent"," Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
urlconnection.setRequestProperty("Connection", "Keep-Alive");
urlconnection.connect();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}

The output for the above program:
***************************
null - HTTP/1.1 302 Found
Server - Lotus-Domino/0
Date - Tue, 11 Jun 2002 08:26:01 GMT
Location - http://192.168.10.55:8001/
Connection - close
Content-Type - text/html
Set-Cookie - DomAuthSessId=0E256929C558C1E725264E4A25F94FF8; path=/
null - null
null - null
null - null
null - null
cookie is - DomAuthSessId=0E256929C558C1E725264E4A25F94FF8; path=/

P.S: The problem is : the servlet is not getting executed....is there anything wrong with the way of sending my cookie, while calling the servlet file(in the domino server)...

Topic: How do I call methods from the driver class ? Previous Topic   Next Topic Topic: Java Help

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use