HttpServletRequestListener

Hi.
Maybe i’m missing something but it seems that implementing com.vaadin.terminal.gwt.server.HttpServletRequestListener with the Root, the onRequestStart is not called before the init like it was in Vaadin 6.x. Is there an alternative?

thanks

Hi,

Even though the Root class in Vaadin 7 takes over some of the roles that Application were previously used for, HttpServletRequestListener still only works when it’s the application that implements the interface. You will thus still require a custom Application class to use HttpServletRequestListener.

You can still continue using your existing Root, you just need to add “application” with the appropriate class name as a servlet init parameter in web.xml. Your Application class does not need anything else than the methods defined in HttpServletRequestListener as long as you also keep the “root” parameter in web.xml.

If you only want to have one hardcoded parameter string in web.xml, you can also remove the “root” parameter if your Application class overrides the getRootClassName method to return the class name of your Root subclass.

Similar details are also discussed in
https://vaadin.com/forum/-/message_boards/view_message/1012789

The init() method on the new Root class has a WrappedRequest parameter.

I tried to get a request attribute by using wrappedRequest.getAttribute(“xxx”) but that returned null.

Am I required to use the HttpServletRequestListener to access request attrbutes?

And what is the difference between the wrappedRequest parameter and the inherited request field on the Root class?

My bad: I had attributes on the brain. I should have been using wrappedRequest.getParameter(“xxx”). Everything is working fine. In fact, its very nice.