You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tremal Naik <tr...@gmail.com> on 2006/11/02 12:11:41 UTC

Modifying the response

Hello,
I'm using SSLExt to manage https redirection in a Struts 1.1 project.
SSLExt (http://sslext.sourceforge.net/) is a framework to let Struts
application easily switch back and forth from a secure channel when a
page displays sensitive data (i.e. password input forms)

If the user requests a page marked as secure, sslext performs a
redirection to a https URL. Sslext extracts all the request parameters
and adds them as a query string to the redirection URL. An example
request-response follow:

REQUEST ->

POST http://cor319.ciccio-pasticcio.com:8080/bitastar/admin/usersAdminAction.do
HTTP/1.0
[.....]

actionName=very&long&parameter

RESPONSE <-

HTTP/1.1 302 Moved Temporarily
Location: https://cor319.ciccio-pasticcio.com:8443/bitastar/admin/resetPasswords.do?very&long&parameter

As you can see above, the parameter 'actionName' has been extracted
and added to the redirection URL as quesry string.

This causes Explorer 6 giving the error "Cannot find server". Mozilla
Firefox is working fine.

I'd like to filter the response to strip the unnecessary query string
from the Location header. Should I use a Valve or a Filter or what?
May you give me some hints or point me to the right resources
(documentation-tutorials) to solve this problem?

Thanks

-- 
TREMALNAIK

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Modifying the response

Posted by Tremal Naik <tr...@gmail.com>.
2006/11/2, Pid <p...@pidster.com>:
> Using a valve seems a bit crazy, even a filter seems excessive.

ok, what do you suggest?

> I'm not quite clear on what the problem is; is it that IE is
> misbehaving, or is it that your app is gaining a query string where it's
> unnecessary?

both. If Mozilla Firefox has not problems with the same app while IE
has (as I wrote in my original post), the conclusion is that IE is
misbehaving. My app, then, is adding an unnecessary query string (as I
wrote in my original post). But I don't have control on it. (SSLExt is
adding that string, as I wrote in my original post)

> If the query string is unnecessary, try to determine why it's getting
> added to the end of the redirected url.  Your SSLExt may be
> misconfigured, or not doing it's job properly - or the Struts components
> doing something improperly.

I inspected SSLExt source code and I see that this is the desired
behaviour. Unfortunately, there is no way to configure SSLExt to avoid
edding the above string. You can see it from the source code.

> If it's meant to be there, and the problem lies with IE you should
> examine the request/response that is causing IE to 404.

The request/response is that one that I pasted (in my original post).
After the 302 response (+ very long Location) by the server IE doesn't
send anymore requests and only displays the error. So, that is not
really a 404, but simply a IE bug

> You may find the IE Developer toolbar helpful, along with a close
> examination of what happens on the server when IE tries to request the
> URL in the redirected response.  E.g. configure an access log valve and
> watch the log as each browser type hits the urls.  check that both see
> the same thing.

when I decided to post to this list I already performed all the above
tasks. If you read carefully my original post you noticed that.

I was not looking for a teacher to tell me how to debug my code. I was
expecting someone gave me his opinion on a possible solution.

thanks anyway

-- 
TREMALNAIK

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Modifying the response

Posted by Pid <p...@pidster.com>.
Tremal Naik wrote:
> 2006/11/2, Tremal Naik <tr...@gmail.com>:
>> I'd like to filter the response to strip the unnecessary query string
>> from the Location header. Should I use a Valve or a Filter or what?
> 
> I noticed that I can change the header Location after the invoke()
> call in a Valve:
> 
> getNext().invoke(request, response);
> String location = response.getHeader("Location");
> if (location != null)
> {
>         response.setHeader("Location",
> "https://cor319.whatever.com:8443/");
> }
> 
> I don't get an IllegalStateException as I expected. Why?
> 
> Do you think this is a correct way to proceed?
> 
> thanks
> 

Using a valve seems a bit crazy, even a filter seems excessive.


I'm not quite clear on what the problem is; is it that IE is
misbehaving, or is it that your app is gaining a query string where it's
unnecessary?


If the query string is unnecessary, try to determine why it's getting
added to the end of the redirected url.  Your SSLExt may be
misconfigured, or not doing it's job properly - or the Struts components
doing something improperly.


If it's meant to be there, and the problem lies with IE you should
examine the request/response that is causing IE to 404.

You may find the IE Developer toolbar helpful, along with a close
examination of what happens on the server when IE tries to request the
URL in the redirected response.  E.g. configure an access log valve and
watch the log as each browser type hits the urls.  check that both see
the same thing.



(It might also be worth noting that Tomcat can automatically redirect to
a secure port, if you're using a Tomcat Realm/Auth implementation).


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Modifying the response

Posted by Tremal Naik <tr...@gmail.com>.
2006/11/2, Tremal Naik <tr...@gmail.com>:
> I'd like to filter the response to strip the unnecessary query string
> from the Location header. Should I use a Valve or a Filter or what?

I noticed that I can change the header Location after the invoke()
call in a Valve:

getNext().invoke(request, response);
String location = response.getHeader("Location");
if (location != null)
{
		response.setHeader("Location", "https://cor319.whatever.com:8443/");
}

I don't get an IllegalStateException as I expected. Why?

Do you think this is a correct way to proceed?

thanks

-- 
TREMALNAIK

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Modifying the response

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Martin Gainty [mailto:mgainty@hotmail.com] 
> Subject: Re: Modifying the response
> 
> can you be more specific on this bug?

I gave a link to the thread that discussed the issue - which you
apparently ignored.  Here it is again:
http://marc.theaimsgroup.com/?t=116136694700001&r=1&w=2

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Modifying the response

Posted by Martin Gainty <mg...@hotmail.com>.
Hello Charles-
can you be more specific on this bug?
Thx,
M-
This e-mail communication and any attachments may contain confidential and privileged information for the use of the 
designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received
this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its 
contents
----- Original Message ----- 
From: "Tremal Naik" <tr...@gmail.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Thursday, November 02, 2006 10:36 AM
Subject: Re: Modifying the response


> 2006/11/2, Caldarale, Charles R <Ch...@unisys.com>:
>> There is a known bug in IE6 that loses the port number while handling
>> redirects.  This thread may be related:
> 
> yes, I use a valve to filter all incoming request to fix this problem.
> 
>> Or it might not be.  You could try IE7 to see if that cures it.
> 
> I'll try, thanks
> 
> Unfortunately the clients may not want to upgrade....
> 
> -- 
> TREMALNAIK
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
>

Re: Modifying the response

Posted by Tremal Naik <tr...@gmail.com>.
2006/11/2, Caldarale, Charles R <Ch...@unisys.com>:
> There is a known bug in IE6 that loses the port number while handling
> redirects.  This thread may be related:

yes, I use a valve to filter all incoming request to fix this problem.

> Or it might not be.  You could try IE7 to see if that cures it.

I'll try, thanks

Unfortunately the clients may not want to upgrade....

-- 
TREMALNAIK

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Modifying the response

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Tremal Naik [mailto:tremalnaik@gmail.com] 
> Subject: Modifying the response
> 
> This causes Explorer 6 giving the error "Cannot find server". Mozilla
> Firefox is working fine.

There is a known bug in IE6 that loses the port number while handling
redirects.  This thread may be related:
http://marc.theaimsgroup.com/?t=116136694700001&r=1&w=2

Or it might not be.  You could try IE7 to see if that cures it.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org