Context:
My development server is a tomcat 7, running on http://127.0.0.1:8080 and my application is called FOO.
I’ve added a RequestHandler to render dynamic files depending on the URL, for instance http://127.0.0.1:8080 /FOO/manifest should return a dynamic list of files instead of the UI.
I added my request handler in the attach() method of my UI class.
Problem:
The first time(after a server restart) that I visit this page: http://127.0.0.1:8080/FOO/manifest, my request handler doesn’t have /manifest in getPathInfo()
Reloading the page (F5) makes it works.
Problem fixed by adding a VaadinServlet and setting the request handler in a SessionInitListener which is set in service(HttpServletRequest request, HttpServletResponse response).
Again, I don’t know if it’s the good way of doing it.
You guys should write a note in the documentation about this issue.
This is not true on my setup: vaadin 7.0.5 + tomcat 6
Here is the output for the first loading, and a refresh:
=================================================================
Vaadin is running in DEBUG MODE.
Add productionMode=true to web.xml to disable debug features.
To show debug window, add ?debug to your application URL.
=================================================================
init
RequestHandler
init
The request handler is only called for the refresh; because the session doesn’t exist on the first loading.
Which is really wrong, because some http client will not keep session from one request to another (for instance, a download program)
The “correct” way to add a request handler is to do it in the servlet:
public class MyServlet extends VaadinServlet {
private final RequestHandler requestHandler = new RequestHandler()
@Override
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
getService().addSessionInitListener(new SessionInitListener() {
@Override
public void sessionInit(SessionInitEvent event)
throws ServiceException {
event.getSession().addRequestHandler(requestHandler);
}
});
}
}
I have a similar problem, but using VaadinPortlet instead a VaadinServlet. As you know, this havent a service method implementation. Where can I set a new requestHandler in order to resolve this issue?
Are there any other solution?