shashank jain
shashank jain

Reputation: 3

how to rewrite the url in java web application?

On Form Submit my url changes from

  1. localhost:8080/Workflow/admin/GetReports?fname=Form1

to

  1. localhost:8080/Workflow/admin/EditReport

Form action is EditReport(Servlet Name).

Now on EditReport i perform the databse operations and forward the request to the GetReports?fname=Formname Servlet using Request Dispatcher.So that i am on the same page which is the first one (1) i started from.

Now Everything works fine on the .jsp page But the url remains unchanged that is the second one (2).

So how to rewrite the url i.e. from admin/EditReport to /admin/GetReports?fname=Form1

Upvotes: 0

Views: 226

Answers (1)

Mecon
Mecon

Reputation: 997

Are you using dispatcher.forward because you are setting some Attributes in the Request?

If not, then you don't need to use Forward. Instead of that, use response.sendRedirect("url for GetReports?fname=Form1")

But If you are setting some Attributes in the request, then I am wondering if your workflow is a correct one because URLs like this "Workflow/admin/GetReports?fname=Form1" should Not be arrived upon after doing some processing. They should be simple HTTP GET requests only.

Upvotes: 1

Related Questions