Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 967
Diablo.Wu Avatar asked Dec 22 '22 12:12

Diablo.Wu


2 Answers

You can find the hooks in HttpServletRequestWrapper.

[Edited to include a link to an example]

Here you can find a fine example.

like image 152
Adeel Ansari Avatar answered Dec 24 '22 01:12

Adeel Ansari


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/

like image 32
Drona Avatar answered Dec 24 '22 01:12

Drona