Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Push problem when recovering from server restart

James Starling
7 years ago Jun 10, 2015 6:21pm
James Starling
7 years ago Jul 23, 2015 5:28pm

My company ended up going through vaadin Pro services. There's an aknowledged issue here but they gave us a workaround. 

Create a filter in your web.xml

    <filter>
        <filter-name>RequestFilter</filter-name>
        <filter-class>com.mycompany.servlet.ApplicationRequestFilter</filter-class>
    </filter>

Then create the class you reference in the web.xml and extend javax.servlet.Filter. Override the doFilter(...) method. Here's what ours looks like.

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
    String transport = request.getParameter("X-Atmosphere-Transport");

    if (transport != null && transport.equals("close"))
    {
        String contextPath = ((HttpServletRequest) request).getContextPath();
        ((HttpServletResponse) response).sendRedirect(contextPath);
    }
    else
    {
        chain.doFilter(request, response);
    }
}