Forward from Servlet to Vaadin App

Hello,
i have a simple Servlet:

[code]
@WebServlet(urlPatterns = { “/start” })
public class FrontController extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.getRequestDispatcher("/myapp").forward(request, response);        
}

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doGet(request, response);
}

}
[/code]which forwards to a simple Vaadin application: myapp

[code]
@Theme(“myapp”)
public class MyappUI extends UI {
private static final long serialVersionUID = 1L;

@Override
protected void init(VaadinRequest vaadinRequest) {
    final VerticalLayout layout = new VerticalLayout();
    final TextField name = new TextField("Your Name");
    final Button button = new Button("Click Me", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            layout.addComponent(new Label(name.getValue()));
        }
    });
    layout.addComponents(name, button);
    setContent(layout);
}

@WebServlet(urlPatterns = {"/myapp/*", "/VAADIN/*"}, name = "MyappUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = MyappUI.class, productionMode = false)
public static class MyappUIServlet extends VaadinServlet {
    private static final long serialVersionUID = 1L;
}

}
[/code]If i call the FrontController servlet from the browser using: http://localhost:8080/myapp/start, it forwards nicely to the Vaadin app. But the next request to the server (clicking the button) displays a (never ending) message: Server connection lost, trying to reconnect.
Of course it is possible to use ‘redirect’ instead of ‘forward’, but this is not wanted. I think the situation arises very often when migrating old web apps partly to Vaadin, but i haven’t found a solution within the documents or by googling.
Any advice is very appreciated, thank you.

Hi,
I think you should override ServletBootstrapHandler.getServiceUrl(…) in order to point always to /myapp.
Take a look at
SpringVaadinServletService
class

HTH
Marco

Hi Marco,

thank you for your fast answer! Yes, it works.
But, firstly: this seems to me such a common scenario, that i wunder why it is not documented.
And secondly: is there any reason, that this is not the default implementation? At least it should be an (annotation-)option of the VaadinServlet Extension which will be generated for each Vaadion app.
That said, isn’t it rather a Vaadin bug within an environment of a java web application?

Kind regards El Goog