J
John Laury
Hello There!
I am having problems establishing a session using httpunit. What I am
trying to do is to access one page (page1.jsp) that leaves a cookie on
my computer and access a second page (page2.jsp) that can only be
accessed if the cookie from the first page is present. If there is no
cookie available from the first page, then the second page would
redirect user to an error page indicating that a session does not
exist.
I have the following piece of code using HTTPUNIT:
..
..
..
WebConversation wc = new WebConversation();
WebRequest request = new GetMethodWebRequest(
"http://www.myhost.com/page1.jsp" );
WebResponse response = wc.getResponse( request );
WebRequest request2 = new GetMethodWebRequest(
"http://www.myhost.com/page2.jsp" );
WebResponse response2 = wc.getResponse( request2 );
String fileContents = response2.getText();
..
..
..
Unfortunately, the 'fileContents' variable contains the error page
that I am redirecting the user in case a cookie is not being
recognized. In other words, when making the second webrequest, it
doesn't seem like the cookie obtained from the first webrequest is
being used. Can anyone tell me why this might be happening?
I would greatly appreciate all responses.
Thanks,
John
I am having problems establishing a session using httpunit. What I am
trying to do is to access one page (page1.jsp) that leaves a cookie on
my computer and access a second page (page2.jsp) that can only be
accessed if the cookie from the first page is present. If there is no
cookie available from the first page, then the second page would
redirect user to an error page indicating that a session does not
exist.
I have the following piece of code using HTTPUNIT:
..
..
..
WebConversation wc = new WebConversation();
WebRequest request = new GetMethodWebRequest(
"http://www.myhost.com/page1.jsp" );
WebResponse response = wc.getResponse( request );
WebRequest request2 = new GetMethodWebRequest(
"http://www.myhost.com/page2.jsp" );
WebResponse response2 = wc.getResponse( request2 );
String fileContents = response2.getText();
..
..
..
Unfortunately, the 'fileContents' variable contains the error page
that I am redirecting the user in case a cookie is not being
recognized. In other words, when making the second webrequest, it
doesn't seem like the cookie obtained from the first webrequest is
being used. Can anyone tell me why this might be happening?
I would greatly appreciate all responses.
Thanks,
John