You won’t be able to get the current URL of a page using Java unless it’s being called from a Request Handler.
This is because microflows are usually called from the client, so you will get the URL used to request the microflow, not the application.