Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Redirecting to a new URL within the same servlet
My application currently consists of one servlet using a UIProvider. This UIProvider selects correct UI by looking at the path in the request. Now I would need to redirect the user (say, by pressing a button) to another UI. That is, I would like to redirect the user to another URL handled by the same servlet.
So, currently the path to my main UI is http://host/myContextRoot/myApp/pathForUI
How can I redirect the user to http://host/myContextRoot/myApp/pathForAnotherUI without hard coding anything but the 'pathForAnotherUI' part? I can get the context root through servlet, but how to get the mapped path of the servlet (ie. 'myApp' here). I was thinking about using Page.setLocation() if I can manage to get the correct path, but is there some other way to do this?