0

I have a java servlet that sets a request attribute which is served for a particular page. On that page, there is some javascript to re-direct to a new page with window.location.href= ...

Will the request attribute be available in the redirected page? I realize this question is a bit confusing, I apologize for that, I'm not really sure how to explain it better, but I thank you in advance for your patience!

Ahamed Mustafa M
  • 3,069
  • 1
  • 24
  • 34
JagWire
  • 269
  • 2
  • 16

3 Answers3

1

A new request will be created for the redirect and you will lose your request-scoped attributes. If you want to retain data, consider storing it in the session instead.

Beau Grantham
  • 3,435
  • 5
  • 33
  • 43
1

Request attributes live only for the period/scope of the request in which they are set.You should use session scoped attributes.

Ahamed Mustafa M
  • 3,069
  • 1
  • 24
  • 34
1

Every time you redirect to a new page, it's a completely new request and a new request object is created. So anything you had in your earlier request object will be discarded. Try saving your data in session or application scope. This should resolve it.

Susie
  • 5,038
  • 10
  • 53
  • 74