Set request header and forward to another application

I am writing a Java-based web application that in a real production environment would be closed by another application that would set certain HTTP request headers before the request gets into my application.

However, in the development environment, I do not have a termination application for which I need to create a web application layout that mimics the same behavior. that is, this false application should set the request headers and redirect or forward or something that I do not know :) to a specific page in my application.

How can i do this?

+4
source share
5 answers

The following articles may help you:


PS
I'm sorry that I provided only links, this was one of my early answers to SO))

+5
source

If you do not want to change your code as suggested by @ user1979427, you can use a proxy server to change headers or add headers on the fly.

For example, in Apache HTTPD you would add something like below and a proxy

Header add HEADER "HEADERVALUE" RequestHeader set HEADER "HEADERVALUE" 

Refer to HTTPD doc

+1
source

You must create an AddReqHeaderForFrowardWrapper request wrapper that passes the name and header values. And override the header-related query methods to return your own header.

0
source

Instead of writing a mock application, I used a browser add-on that allowed me to add custom headers!

-2
source

To set the header in java you can use:

 request.setHeader(attributeName, attributeValue); 

And to redirect to another page, you can use:

 request.sendRedirect(URL); 
-4
source

All Articles