2

I have to pass a token (string) in a HTTP request header to a 3rd party web application. ie from my java web application, I will set the HTTP request header value and the 3rd party web application will receive the HTTP request header.

I have successfully set the request header from my Spring MVC controller and verified it by redirecting it to a simple jsp file in the same application.

Then I tried perform a Redirect to the simulated 3rd party web application , Unfortunately the token request header is never displayed on the simulated 3rd party web application.

I believe that I am setting the request header correctly so the problem might be with the way I am attempting to transfer it to the simulated 3rd party web application.

Here's the code I used in my spring Controller for redirection,

HttpServletRequest request = new CustomHttpServletRequest(httprequest);

CustomRedirectView rv = new CustomRedirectView();

rv.sendRedirect(request, response, "redirectUrl", true);

where CustomHttpServletRequest - class which extends HttpServletRequestWrapper and i have overridden getHeader method as per my requirement

    CustomRedirectView - class which extends RedirectView
    redirectUrl - redirect url for the 3rd party web application

I will be really grateful for any help or advice on this challenge.

StackUser
  • 67
  • 2
  • 8
  • check http://stackoverflow.com/questions/3763015/custom-header-not-inserted-in-request-in-servlet – apurvc Jul 22 '14 at 06:35
  • thanks for reply. i have gone through the link you suggested. but its not meeting my requirement. I can't go for requestDispatcher.forward() because my redirect url is in a different context (application). also if i use forward(), the url will not change in the address bar. is there any other way to achieve this? – StackUser Jul 23 '14 at 21:00
  • It's there in the same question, create a filter mapped to the redirected url and add the custom header. check answer by @BalusC – apurvc Jul 24 '14 at 04:30

0 Answers0