• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet filters and request headers

 
Srivatsan Varadarajan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a filter to check the login access to my application. Before It comes to the filter, the user -id is already set in the request header as one of the attributes. But, by the time , it gets to the filter, I lose that header. The reason why I say that I am losing the header name is this: I took the logic and put that in my action class and print out the header and it totally works. Should it be the same request that gets passed either way? I would really appreciate somebody's help.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sri_varada",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
by the time , it gets to the filter, I lose that header

Requests go through all parts of the filter chain BEFORE they get to the servlet so that sounds rather odd.

Exactly how and where are you setting this user id header?

How many filters do you have?

Bill
 
Srivatsan Varadarajan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bill for replying during the weekend. There is first an application url that the users go to and this goes through our LDAP server where the user-id is verified and we have a request header called "user" set there. So, what essentially we are trying to do in our filter is to check for the presence of that request header, "user". For some reason, when we print out all the request header name and value, that "user" request header is not among them. But I know for sure that the request header , "user" is set because I took the same code that I wrote in filter and put it in the struts action class and print out all the names and values, it is present. So, I don't understand why the filter and the action class are getting totally two different request objects. I have only one filter that checks for that "user" request header. Please let me know if I can provide any more details. I really appreciate your help.
 
abhijit Ohal
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IF you are using struct for developing webApplication then in struts-config.xml for your login action make redirect property false.

OR IF you are using servlet for developing webApplication use forward instead of response.sendRedirect().

eg.
<code>
<action path="/ResetPassword"
type="ResetPasswordAction"
name="ResetPasswordForm"
scope="session" >
forward name="login" path="/Camp.jsp" redirect="false"/>
</action>
</code>
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I bet that Abhijit Ohal identified the problem! When a request is redirected, the client creates a NEW request so your added header vanishes.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic