Retrieving actual URL of a request from Filter

Hi,

I have created a new filter and in that filter I am trying to getting the URL of the request but I am getting an output as “http://localhost:8083/vaadinServlet/UIDL/”. But, the actual URL that I can see on the browser is “http://localhost:8083/#main/0/reports/abc

Please find the below code snippets for reference:

Filter class:

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
        throws ServletException, IOException {

    log.info("request.getRequestURL() :: "+request.getRequestURL());
}

Screen class(have created route):

@Route("reports/abc")
public class AbcBrowse extends StandardLookup<Abc> {

Browser URL:
image

Version Details:
Jmix version: 1.5.0
Jmix Studio plugin version: 2.0.0-231

Please help if there is any other way to retrieve the actual URL that is in the browser.

Hi,

You have 2 options:

  1. Using URL Route Generator generate get a route for a screen
  2. Get current location as URI object: URI location = AppUI.getCurrent().getPage().getLocation()

Regards,
Gleb

Thanks for the answer. But is there any way to get it at filter level so that it can be used to process request of specific pages.

I’d recommend implementing a io.jmix.ui.navigation.NavigationHandler bean with higher precedence then built-in ones. Take a look at the io.jmix.ui.navigation.navigationhandler.ScreenNavigationHandler for the example how to handle routes and redirect the request if needed.

Regards,
Gleb