public void service(Request req, Response res) throws Exception { MessageBytes mb = req.requestURI(); ByteChunk requestURI = mb.getByteChunk(); try{ String uri = requestURI.toString(); if (contextRoot!=null && requestURI.startsWith(contextRoot)) { uri = uri.substring(contextRoot.length()); } File file = new File(getRootFolder(),uri); if (file.isDirectory()) { uri += "index.html"; file = new File(file,uri); } if (file.canRead()) { super.service(uri, req, res); return; } else { serviceDynamicContent(req, res); } } catch (Exception e) { if (getLogger().isLoggable(Level.SEVERE)) { getLogger().log(Level.SEVERE, e.getMessage()); } throw e; } }
public void service(Request req, Response res) throws Exception { MessageBytes mb = req.requestURI(); ByteChunk requestURI = mb.getByteChunk(); try{ String uri = requestURI.toString(); if (contextRoot!=null && requestURI.startsWith(contextRoot)) { uri = uri.substring(contextRoot.length()); } File file = new File(getRootFolder(),uri); if (file.isDirectory()) { uri += "index.html"; file = new File(file,uri); } if (file.canRead()) { super.service(uri, req, res); return; } else { serviceDynamicContent(req, res); } } catch (Exception e) { if (logger.isLoggable(Level.SEVERE)) { logger.log(Level.SEVERE, e.getMessage()); } throw e; } }
@Override public Adapter configureAdapter(SelectorThread st) { String adapterClass = System.getProperty(ADAPTER); Adapter adapter; if (adapterClass == null){ adapter = new StaticResourcesAdapter(folder); } else { adapter = (Adapter)ClassLoaderUtil.load(adapterClass); } if (adapter instanceof StaticResourcesAdapter){ ((StaticResourcesAdapter)adapter).setRootFolder(folder); } if (adapter instanceof DynamicContentAdapter){ ((DynamicContentAdapter)adapter).setContextRoot("/"); } return adapter; }
public void service(Request req, Response res) throws Exception { MessageBytes mb = req.requestURI(); ByteChunk requestURI = mb.getByteChunk(); try{ String uri = requestURI.toString(); if (contextRoot!=null && requestURI.startsWith(contextRoot)) { uri = uri.substring(contextRoot.length()); } File file = new File(getRootFolder(),uri); if (file.isDirectory()) { uri += "index.html"; file = new File(file,uri); } if (file.canRead()) { super.service(uri, req, res); return; } else { serviceDynamicContent(req, res); } } catch (Exception e) { if (logger.isLoggable(Level.SEVERE)) { logger.log(Level.SEVERE, e.getMessage()); } throw e; } }