Logo Search packages:      
Sourcecode: jaminid version File versions  Download package

String com::prolixtech::jaminid_examples::SimpleServer::demultiplex ( Request  connRequest,
Response  connResponse 
) [inline]

the main function of the oracle, is to demux the request and produce an output that is relative to the request.

in this example, it is a static HTML, that is all we care about for now.

Parameters:
connRequest 
connResponse 
Returns:
the output

Reimplemented from com::prolixtech::jaminid::ContentOracle.

Definition at line 44 of file SimpleServer.java.

References com::prolixtech::jaminid::Request::getLocation(), com::prolixtech::jaminid::Response::sendFile(), and com::prolixtech::jaminid::Response::setStatus().

                                                                          {
        String loc = connRequest.getLocation();
        if(loc.equals("/")) loc = DEFAULT;
        File x = new File(ROOT_PATH + loc);
        
        
        try {
            x = x.getCanonicalFile();
            if(! (x.getAbsolutePath().startsWith(root_canonical))) throw new IOException("Not within filesystem limits");
            connResponse.sendFile(x);
        } catch (IOException e) {
            connResponse.setStatus(Protocol.NOT_FOUND);
        } catch (Exception e){
            connResponse.setStatus(Protocol.INTERNAL_SERVER_ERROR);
        }
        return "";
        
    }


Generated by  Doxygen 1.6.0   Back to index