I am facing a problem while trying to test a particular flow of my application.The details are given below:
The controller servlet of my main application reads the header "Referer" from the request object and then based on this it forwards the request to appropriate servlets.For testing my application I am writing a test servlet which receives a request object from a test jsp and sets all the necessary attributes in the request object and passes this request object to the doGet () method of the main application's controller servlet. But while trying with this I find that the main controller fails to forward to the correct servlet because it receives incorrect referer information. So my question is how can I set my customised "Referer" in the header of the http request so that the application's controller servlet forwards to the correct servlet?Is there any means to set the request header in servlet or jsp?
This sounds like a job for a custom implementation of HttpServletRequestWrapper. Because you can not directly set a request header value. Your request wrapper would just provide a version of getHeader that watches for a "Referer" request and returns your test value. All other calls being handled by the wrapped request. Bill [ July 09, 2004: Message edited by: William Brogden ]
subject: how to set the header in http request object ?