Hy, I have a code who intercept all request(GET & POST), and eventually redirect to another page, with a form. I want that when the user post the form, the initial intercepted request is executed
My actual code:
public void doFilter(ServletRequest originalRequest, ServletResponse res, FilterChain chain){
originalRequest.getRequestDispatcher("/message").forward(request, res);
}
...
@RequestMapping("/message", method=GET)
public void showMessageForm(...){
...
}
@RequestMapping("/message", method=POST)
public void messageOk(ServletResponse res, ModelAndView mav){
//redirect to the originalRequest.
????
}
The originalRequest can be both GET or POST. If it's a post, I want the content of the form to be transmit too.
Thank you !
Your messageOk method will need to return a page with a form that has hidden fields for each field they passed + an Ok button. So something like:
<form method="POST or GET" action="origin url">
<input type="hidden" name="param1" value="value for param1"/>
... for each input ...
<input type="hidden" name="paramN" value="value for paramN"/>
<input type=submit" value="Continue"/>
</form>
This should work as long as you don't have a POST that is uploading a file. You might want to consider a simpler flow in your application, like forcing this page only when somebody logs in.