How do you add a http protocol header value in HttpServletRequest ?

16,795

Solution 1

You can find the hooks in HttpServletRequestWrapper.

[Edited to include a link to an example]

Here you can find a fine example.

Solution 2

HttpServletRequest objects are read-only. You cannot modify them. But you can definitely extend their functionality by employing a decorator pattern and add mutability in the extended class. Take a look at the following post:

http://wilddiary.com/adding-custom-headers-java-httpservletrequest/

Share:
16,795
Diablo.Wu
Author by

Diablo.Wu

Updated on June 12, 2022

Comments

  • Diablo.Wu
    Diablo.Wu almost 2 years

    How do you add a http protocol header value in HttpServletRequest at a Filter,before call request.getHeader() and get the header value?

  • Clint Eastwood
    Clint Eastwood about 8 years
    I found snippet more useful than other suggested in other answers. Thanks!