A while ago I sent you this problem and you responded with a great
suggestion that worked,
something like:
assertEquals(302, theResponse.getResponseCode());
assertEquals("http://localhost:8080/omac/Menu.jsp",
theResponse.getHeaderField("Location"));
Worked great....
Uhmmmm.. I guess I did a bad thing, I upgraded to Tomcat 4.1.27. No
workie and more. I get
a response code of 302, but the theResponse.getHeaderField("Location")
returns null.
I noticed this in the log:
DEBUG|Thread-5 |2003-09-16
15:33:12,464|GetMethod|GetMethod.readResponseBody(HttpState,HttpConnection)
DEBUG|Thread-5 |2003-09-16
15:33:12,464|HttpMethod|HttpMethodBase.readResponseBody(HttpState,HttpConnection)
INFO |Thread-5 |2003-09-16
15:33:12,464|HttpMethod|HttpMethodBase.execute(): Received 302 response,
but followRedirects is false. Returning 302.
DEBUG|Thread-5 |2003-09-16
15:33:12,484|HttpClient|HttpClient.startSession(String,int,boolean):
Host:localhost Port:8080 HTTPS:false
DEBUG|Thread-5 |2003-09-16
15:33:12,484|HttpConnection|HttpConnection.HttpConnection
DEBUG|Thread-5 |2003-09-16
15:33:12,484|HttpConnection|HttpConnection.open()
Is there some where to set this to true? Is this the problem? Is it a
tomcat thing? Or a Cactus thing?
-Richard
----- Forwarded by Richard R Brandt/AEPIN on 09/16/2003 04:02 PM -----
Richard R Brandt
06/10/2003 04:31 PM
To: [EMAIL PROTECTED]
cc:
Subject: I have a jsp that does a redirect, can I test the resulted
redirected
page?
I love your production but I have a question.
I have a JSP that does a redirect to another JSP. I want to beable to
test that I did in fact get a re-direct. I noticed in the Cactus logs
there was in fact a redirect, but I can't find any method in the
response/request/session objects that would return if this happend.
The HTML that I get back is the HTML for the JSP I am testing.
Here is a code snipet of the JSP I am testing:
<% userID = (String) request.getParameter ("user");
if (userID != null) {
userID = userID.toUpperCase ();
}
loginUser = ldapServices.findPerson (new String ("cn=" + userID));
if (loginUser == null){
loginUser = new Member ();
loginUser.setDisplayName ("Undefined");
}
session.setAttribute (OMACProperties.SESSION_LOGIN_USER, loginUser);
omacRequestID = (String) request.getParameter ("OMACRequestID");
%>
....
<body>
<% if (omacRequestID == null) {
if (userID.length () == 0)
response.sendRedirect("TerminalErrorPage.jsp?msg=Anonymous
access to the OMAC is not allowed. Please close the browser and log into
the network with a valid user ID");
else
response.sendRedirect("Menu.jsp");
} else {
if (userID.length () == 0)
response.sendRedirect("TerminalErrorPage.jsp?msg=Anonymous
access to the OMAC is not allowed. Please close the browser and log into
the network with a valid user ID");
else
response.sendRedirect("Update.jsp?OMACRequestID=" +
omacRequestID);
}%>