Handling UIDL request

I’m developing server application with vaadin.

The app requested with URL, like http://localhost/contextRoot/ID.

With WebKit browser (Chrome or Safari), for the first access, a client request http://localhost/contextRoot/ID and a server respond full content.
The content may be cached to the browser.
Then on the next access, the client request http://localhost/contextRoot/UIDL.
The app does not work properly because cannot get ID from request URI.

Are there any workarounds?

The UIDL requests are Vaadins internal AJAX communication method; normally there is no reason to intercept these. What exactly are you trying to do?

Our application always need ID (from the request URL http://localhost/contextRoot/ID) to identify which system is selected.
ID is not user’s ID, it is such as group ID. Users are classified to one of such groups.

For example, system have two groups: Apple, Orange.

Then, the app requires to be accessed with the url: http://localhost/contextRoot/Apple or http://localhost/contextRoot/Orange.

The app retrieves the group ID from the request URI with HttpServletRequest#getRequestURI.

It seems that Vaadin internal UIDL request affects the request URI, and omits original URI.

So I want to know how to get original URI by the other way.

I tested this, and you are correct; if there are no separate mappings, the all UIDL calls will go to /UIDL. But, there is hope: Each time the URL changes, the browser makes a request to the server with the new UI. This request does have the correct requestUri. So, what you can do, is when listening in the Servlet you check each request that hasn’t got UIDL or VAADIN or APP; that is the request URI. When/if the user changes the URI, you will get a new request, and can change that. In the meantime, just store the URI in your Application class, you can get to it by using ApplicationServlet.getExistingApplication().