0

I have a JSP page to search customers. This page calls the controller, which execute a method to return a list of customers and after forward to the origin URL;

I used to forward : request.getRequestDispatcher(urlOrigin).forward(request, response);

(note 1: request.getHeader("Referer") was used to get complete origin URL )

(note 2: There a method to split the complete origin URL and get name page )

Since it, I have the following url in the browsear :

(http://domain/ProjetoT/mvc)

Its the url of my controller

If I search a customer again won't work, because the controller url will be recognized as origin url.

I Tried use : response.Sendredirect(urlOrigin);

But I lost my object and the list of customers didn't rendered.

Anyone can help me please?

Thanks!

1 Answers1

0

Instead of intially accessing the JSP page directly in the browser, you could access it through the same controller used to process the search. To do that you would have to program your controller to detect if you are in initial display mode or if you are in "submit" mode. This is typically done by checking the presence of a parameter that is sent in the submit.

So in initial display mode, your controller would just forward to the JSP without any further processing, while in submit mode it would do what it is currently doing. This way you would be using the same URL for both the initial display and the submit and the problem you described should go away (that is, if I understand your question correctly).

David Levesque
  • 22,181
  • 8
  • 67
  • 82