Package com.ramforth.webserver.http.modules

Examples of com.ramforth.webserver.http.modules.HttpFileModule


    public WebServerFileExample() {
        // instantiate a new web server
        WebServer webServer = new WebServer();

        // add a file module serving only static files
        HttpFileModule httpFileModule = new HttpFileModule();
       
        // instantiate a single static file resource
        HttpFileResource staticFile = new HttpFileResource();
        // set the path we can use to open the file e.g. with a web browser
        staticFile.setRelativePath("/index.htm");
        // set the path where the file is located on disk
        staticFile.setServerPath(WebServerFileExample.class.getResource("/examples/staticFileTest.htm").getPath());
        // add the newly created resource to the module
        httpFileModule.getResources().addResource(staticFile);
       
        // add the module to the server
        webServer.addModule(httpFileModule);

        // create an http listener for InetAddress.getLocalhost() on port 11111
View Full Code Here

TOP

Related Classes of com.ramforth.webserver.http.modules.HttpFileModule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.