One servlet w/ two controllers

I’m attempting to test a theory in Vaadin and before I get in too deep I wanted to even see if it was possiible. Currently I’m trying to utulize vaadin inside of an existing system. I can’t change the current system in any way, nor can I change the normal servlet process. My workaround here is to create my own custom HttpServlet and hand off the request to either the existing servlet or to the vaadin servlet.

An example (this is a crude example attempting to show what I am attempting to do and in no way reflects the final code implementation):

private final NormalServlet normalServlet = new NormalServlet();
private final VaadinServlet vaadin = new VaadinServlet();

private enum POST_TYPE{
post,
get
}

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
processRequest(request, response, POST_TYPE.get);
}

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
processRequest(request, response, POST_TYPE.post);
}

private void processRequest(HttpServletRequest request, HttpServletResponse response, POST_TYPE type) throws ServletException, IOException{
if (request.getPathInfo().contains(“/vaadin/”)){
vaadin.service(request, response);
}else{
if (type == POST_TYPE.get){
normalServlet.doGet(request, response);
}else{
normalServlet.doPost(request, response);
}
}
}

@Override
public void init() throws ServletException{
normalServlet.init();
vaadin.init();
}

@Override
public void destroy(){
normalServlet.destroy();
vaadin.destroy();
}

Hi,

personally I would use a request dispatcher to route the request to the vaadin servlet.
In addition, please keep in mind that you have to map both the ‘/vaadin’ path or whatever it is AND the ‘/VAADIN’ path.