Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

session attributes are getting lost after 301 header redirect  RSS feed

 
jar pondy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

We are trying to debug an issue in filter class, where the attributes in the session which are set explicitly seems to be lost for the next request even the session id seems to be the same.

Below is the code snippet which invalidates a session and creates a new session and sets the value and send 301 request back to the browser.

When i send a request with "cy" as parameter and we are changing the current session country from india to swiss.
www.mydomain.com/in?cy=ch



Now the browser sends the request with www.mydomain.com/ch
and in the filter i do



COUNTRY_ISO seems to be null.Ideally it should be "ch".

So, to find out what attributes are removed,we have implemented HttpSessionAttributeListener and overridden attributeAdded/attributeRemoved/attributeReplaced methods.


And when we see the logs..it prints source class as org.apache.catalina.session.StandardSessionFacade with COUNTRY_ISO as removed.

But this does not help much.
We want to find out which class actually triggered remove attribute from and why?


Regards,
Raj
 
Ivan Jozsef Balazs
Rancher
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could produce a stack trace to see the whole call chain. The question is: would even that help?
 
jar pondy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I can try that to check which part of the code is called in while removing the attribute.

Regards,
Raj
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


If this was my problem I would first check that request.getParameter("cy") actually retrieves a usable value. Good practice is to always check request parameters before using them.

Bill
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!