Package com.ramforth.webserver.http.resources

Examples of com.ramforth.webserver.http.resources.HttpFileResource


        // add a cgi module using perl as backend for files ending with .pl (adjust path to perl executable as needed)
        HttpCgiModule httpCgiModule = new HttpCgiModule("/usr/bin/perl", ".pl");
       
        // instantiate a single file resource
        HttpFileResource perlFile = new HttpFileResource();
        // set the path we can use to open the file e.g. with a web browser
        perlFile.setRelativePath("/index.pl");
        // set the path where the file is located on disk
        perlFile.setServerPath(WebServerCGIExample.class.getResource("/examples/perlCgiTest.pl").getPath());
        // add the newly created resource to the module
        httpCgiModule.getResources().addResource(perlFile);
       
        // add the module to the server
        webServer.addModule(httpCgiModule);
View Full Code Here


        // 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);
View Full Code Here

    @Override
    public boolean processHttpContext(IHttpContext httpContext) {
        if (isGetOrHeadOrPostMethod(httpContext.getRequest())) {
            if (resourceExists(httpContext.getRequest().getUri().getPath())) {
                HttpFileResource fileResource = getFileResource(httpContext.getRequest().getUri().getPath());

                switch (httpContext.getRequest().getMethod()) {
                    case GET:
                        writeFileResourceToHttpResponse(httpContext.getResponse(), fileResource);
                        break;
View Full Code Here

TOP

Related Classes of com.ramforth.webserver.http.resources.HttpFileResource

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.