users@grizzly.java.net

Grizzly with static content and servlets

From: Hiran Patel <hiranp_at_yahoo.com>
Date: Fri, 15 Jul 2011 11:10:48 -0700 (PDT)

Folks,

I am trying to follow the example here: http://grizzly.java.net/nonav/docs/1.9/apidocs/com/sun/grizzly/http/embed/GrizzlyWebServer.html using Grizzly 1.9.36 (JDK 5)

It seems Grizzly wipes out the original static adapter when the servlet adapter is added. If I include the following lines of code (
ServletAdapter ServletAdapter = ...) the static content is no longer
served. Instead it gives me a "Resource not Found".

GrizzlyWebServer gws = new GrizzlyWebServer(8080, "/var/www");
       
try {
    ServletAdapter sa = new ServletAdapter();
    // Fails too: ServletAdapter sa = new ServletAdapter("/var/www");
    sa.setHandleStaticResources(true);
    // Fails too: sa.addRootFolder("/var/www");
    sa.setContextPath("/main");
   
    Servlet servlet = (Servlet)ClassLoaderUtil.load("com.my.MainServlet");
    sa.setServletInstance(servlet);
    
    System.out.println("Root is:"+sa.getRootFolders());
   
    ws.addGrizzlyAdapter(sa, new String[]{"/main"});
    gws.start();
    } catch (IOException ex) {
        System.out.println("ERROR: Problem loading Webserver");
        System.out.println(ex.getMessage());
        System.exit(1);
    }


I realy don't know how to proceed...

Thanks in advance,
Hiran