'How to access HttpServletRequest from vaadin UI class in vaadin 8

In our vaadin 6 application, we can access the HttpServletRequest object from onRequestStart method from our vaadin Application sub-class. We need to access the HttpServletRequest to obtain parameters passed by the caller which starts our vaadin application (an HTML Form). Now we are converting the application to vaadin 8. I was not able to find a method in vaadin UI similar to onRequestStart that exposes the raw HttpServletRequest that starts the vaadin application. I tried to use getParameter method of the VaadinRequest object passed to UI's init method, however, this could not retrieve the parameters passed. How can I get the parameters in the raw HttpServletRequest in vaadin 8?



Solution 1:[1]

I'm surprised that they can not be retrieved through getParameter(...).

Since you're running on a servlet, the VaadinRequest will be a VaadinServletRequest. After casting it to this subclass, you can use getHttpServletRequest() to get the wrapped request.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Erik Lumme