-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Joe,

On 9/8/16 1:38 PM, Joe Tseng wrote:
> FYI I'm using Tomcat v7.x.
> 
> I guess I misunderstood what happens when I use sendRedirect() - it
> sends a new request, not a new response - but the effect is the
> same. That was what I came away with when I read this:
> 
> http://javarevisited.blogspot.com/2011/09/sendredirect-forward-jsp-ser
vlet.html

Oh,
> 
right: that's a misunderstanding about HTTP itself. The
sendRedirect method returns a response to the client and then hangs up
the phone. The client is expected to make a follow-up request in
whatever way it chooses. There are certain response codes that
indicate certain things should be done, but the client is free to do
whatever it wants.

> In any case, I gave up on using the header to pass additional items
> from the server to the browser and ended up just using cookies.

Technically, cookies are just headers :) But they are documented to be
sent BACK to the server once they've been set.

> Unless someone shows me otherwise, everything I saw online showed 
> how to use jQuery/xhr/your JS tool of the month to get header
> values from a GET/POST response; meanwhile I never figured out how
> to extract those values after a document was rendered in a
> traditional MVC app.

For MVC, you'd have to know how the requests are being sent and
responses are being processed. You probably have to "listen" for the
response and grab the response headers from there.

I'm interested... what kind of work are you doing, here? Do you have a
fat client with a web-services back end or something?

- -chris

> On Thu, Sep 8, 2016 at 11:22 AM Christopher Schultz < 
> ch...@christopherschultz.net> wrote:
> 
> Joe,
> 
> On 9/6/16 3:36 PM, Joe Tseng wrote:
>>>> I inherited a codebase that calls 
>>>> HttpServletResponse.sendRedirect() to another page after a
>>>> user is successfully logged in. I want to be able to insert a
>>>> header value before that redirection is executed. I tried to
>>>> simply add a HttpServletResponse.addHeader()/.setHeader() to
>>>> the response object before the redirect is called, but it
>>>> seems a new response object is used and sent to the browser.
>>>> Is that assessment correct? Is there any way for me to modify
>>>> the redirect before it's sent or do I have to use
>>>> .forward()?
> 
> Tomcat version?
> 
> This should work. Calling response.setHeader or response.addHeader
> and then response.sendRedirect() should include your custom
> headers. What makes you think that "a new response object is
> used"?
> 
> -chris
>> 
>> ---------------------------------------------------------------------
>>
>> 
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>> 
>> 
> 
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJX0bt8AAoJEBzwKT+lPKRYTMUQAI45TDfn358qRBl3zmLFEpkD
2WcGkqhDvtAAkOeXKqrOpbJW4D22uZEkQo1YdEhAMMosZOIltcp/gLR7e7hSXv9h
nxj+wQ93PzSVt/MOKTTfppGFy1r8dlRFzA/vWpSLy/k8Ab4b3ILyvrJlD+YSUpow
2e1Zsc2+naTmgrPpS3Js89HYWBq5nvcOKHLUMK8wD5F8YohkLWiymBQjwaHXYsEo
eC5WZPbV7bj8FDhKQXXe7HMvgXxN67sSZC/3YJ45EBVz5GprvChZeVOtmE5a5v7h
0L2w0hSzy/0JyQApjnLGxoss9soX2vBM8FnRoCglpYwQF0xTqJ/AYoRicvBwbqdx
jW/g7K/JZeftCNsKwqGhVCwjYZstAnMClP1lv259Tne2iSQizHdwQf/WkE4AaoAg
qF07nMdBulK9pn7KEC0G4ZD/D1PfFK0cUjA6SeG/+KgjfAB9HQfydpMjBASdTlKo
HA9KvebTq/BvFthjgXF4C2NIvKNJpGWzIEnnp2+kLWiEmxshCooZcGJVs0GRiS7c
M+AR1hVjx8Bpa907CgMrbUmjPgJkP9jqG7OJSIy6mJhYNraoGk8c4wp6h6M8Hw+y
7QBmECh4fMsXLUswpBjeKSsRndafTu8vcfBjt+6s3jcrOoVyKzHTXF+KrJuIKEk+
AmfCXWFBSB3GcuNbPpyy
=20YS
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to