0

I have this code that add servlet, and the url

        DeploymentInfo servletBuilder = deployment()
                .setClassLoader(ServletServer.class.getClassLoader())
                .setContextPath(MYAPP)
                .setDeploymentName("test.war")
                .addServlets(
                        servlet("MyServlet", MessageServlet.class)
                        .addInitParam("message", "My own Servlet")
                        .addMapping("/myservlet"));

        DeploymentManager manager = defaultContainer().addDeployment(servletBuilder);
        manager.deploy();

        HttpHandler servletHandler = manager.start();
        PathHandler path = Handlers.path(Handlers.redirect(MYAPP))
                .addPrefixPath(MYAPP, servletHandler);
        Undertow server = Undertow.builder()
                .addHttpListener(8080, "localhost")
                .setHandler(path)
                .build();
        server.start();  

However, I have tried to use this version but its not working

I have this code that add servlet, and the url

.addServlets(servlet("MyServlet", MessageServlet.class)
  .addInitParam("message", "My own Servlet")
  .addMapping("/myservlet"));

This doesn't work because the latter servlet(url) part was working while the former didn't . I mean myservlet1 was working while myservlet wasn't working anymore

olyjosh
  • 431
  • 7
  • 15
  • Please, tidy up your code in post a bit. – Rafal G. Jan 20 '15 at 22:38
  • After tidying up this code, no body could give me the answer? Is it that undertow is so poorly documented that simple thing like this is missing out in the doc? – olyjosh Feb 13 '15 at 01:29
  • how do I mark a question as duplicate and what number of reputation is required – olyjosh Jan 01 '16 at 11:06
  • @olyjosh I already marked this question as duplicate, see the banner on top and on the bottom of this post. – Tunaki Jan 01 '16 at 11:29

0 Answers0