Dear All,
I have designed a website. In that website, I am trying to get the user name and password of a user and trying to get the authentication for the user from my "WEB SERVER" and from my "DOMINO SERVER"...the authentication is done for both the cases as expected. also if i try to get the cookies from the address bar, using the i can get two cookies, one from the WEBSERVER and another one from the DOMINO SERVER.
but if i approach the same authentication process, from my below program, the problem is, after authentication, i can get only the cookie sent by the WEB SERVER. I can't able to get the cookie sent by my DOMINO SERVER. This is becoz of the reason that, as soon as i get authenticated from the domino server, it is going to the second page. Since the cookie for the domino server exists only in the first page, i can't able to catch the cookie present in the first page....I am using the statement, "HttpURLConnection.setFollowRedirects(false);". but it is still redirected to the second page from the first page... how to avoid this and catch the cookie of the DOMINO SERVER.
Pl. help me yaaar.
I am hanging over here for the past 18 days...very badly.
pl. suggest me some ideas......
then,
If i contact thru the browser, the browser can fetch both the cookies....but thru my program, i cant able to get both the cookies...pl. suggest me with some ideas, for stopping the redirection process of the login page to the next page and to catch the cookie of the DOMINO SERVER.
Any kind of suggestions are highly welcome...and very highly appreciatable....
bye,
Sakthivel S.
P.S: waiting for any kind of suggestions....very eagerly.
My program and the output for ur kind persual:
**********************************************
import java.io.*;
import java.net.*;
public class authen_new
{
public static void main(
String args[]) throws Exception
{
String cookie="";
HttpURLConnection urlconnection = null;
URL theurl = new URL("http://www.maintenance.com/loginme");
HttpURLConnection.setFollowRedirects(false);
HttpURLConnection hurl = (HttpURLConnection)(theurl.openConnection());
hurl.setRequestMethod("POST");
hurl.setRequestProperty("referer","/dologin");
hurl.setDoInput(true);
hurl.setDoOutput(true);
String idpassword = "username=allusers&password=12345";
hurl.connect();
OutputStream o= hurl.getOutputStream();
byte[] by= idpassword.getBytes();
o.write(by);
o.flush();
o.close();
int ic=0;
cookie=hurl.getHeaderField("Set-Cookie");
String key="";
while (ic<=10)
{
key = hurl.getHeaderFieldKey (ic);
if(ic<=10)
{
String value = hurl.getHeaderField (ic++);
System.out.println(key + " - " + value);
}
}
hurl.disconnect();
System.out.println(cookie +"*************");
}
}
The Output of the above program:
**************************************
null - HTTP/1.1 302 Found
Date - Fri, 15 Nov 2002 14:10:36 GMT
Server - Apache/1.3.26 (Unix) mod_jk/1.2.0 mod_perl/1.27 PHP/4.2.2 mod_ssl/2.8.10 OpenS
SL/0.9.6d
Set-Cookie - SSOAuthSessionID=52c0975bf42d29333a9572064858167e;path=/;
Location - /homepage.nsf/SolutionsDisplay?OpenForm
referer - /dologin
Connection - close
Content-Type - text/plain
null - null
null - null
null - null
SSOAuthSessionID=52c0975bf42d29333a9572064858167e;path=/;*************