You have developed a servlet that extracts customer checking account transaction history and sends it to the browser as a text file. A few months later, you have been asked to ensure that the customer data is sent in encrypted format. How will you do it without changing the servlet code?
Select 1 correct option. a Apply a filter to the servlet and encrypt the text on-the-fly while it is being sent to the client. b Apply a filter to the servlet and pass a HttpServletResponseWrapper instead of the original HttpServletResponse to the servlet. c Apply a filter to the servlet and pass a HttpServletRequestWrapper instead of the original HttpServletRequest to the servlet. d This cannot be done without change in the servlet code.
Can a HttpServletRequestWrapper modify the header of a request within javax.servlet.Filter implementing class?
Ofcourse, it's possible, but you can't directly modify the header of the request(as their is no setHeader(String) method), but you can override the getHeader() method in such a way that it will give you what you expected it to return. Look at the code below