I've been scratching my head for hours now. I'm working expanding a web app and I've come across this problem:
I have a class called SelectionHandler which uses cases in a doPost() method to forward to the right app:
private void userEditor(HttpServletRequest request, HttpServletResponse response) {
response.setHeader("destination", "edit_user");
HttpRedirectHandler.forwardToURL(request, response, "EditUser");
}
Now this servlet is designed to be re-used, so it will decide where to forward the user next:
String header = response.getHeader("destination");
if (header.equals("price_manager")) {
destination = "PriceManager";
} else if (header.equals("new_user")){
destination = "NewUser";
};
and then
HttpRedirectHandler.forwardToURL(request, response, destination);
But before that happens I've been redirecting the user to a JSP page. Problem is, when I do that the information where I wanted to go gets lost.
Can someone advise me as to what is the best way to retain this information? I tried reading the header and writing it again to a header in the JSP page, but I'm not sure that is actually possible.