|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.klomp.snark.web.BasicServlet
class BasicServlet
Based on DefaultServlet from Jetty 6.1.26, heavily simplified and modified to remove all dependencies on Jetty libs. Supports HEAD and GET only, for resources from the .war and local files. Supports files and resource only. Supports MIME types with local overrides and additions. Supports Last-Modified. Supports single request ranges. Does not support directories or "welcome files". Does not support gzip. Does not support multiple request ranges. Does not cache. POST returns 405. Directories return 403. Jar resources are sent with a long cache directive. ------------------------------------------------------------ The default servlet. This servlet, normally mapped to /, provides the handling for static content, OPTION and TRACE methods for the context. The following initParameters are supported, these can be set on the servlet itself:
resourceBase Set to replace the context resource base warBase Path allowed for resource in war
Nested Class Summary | |
---|---|
static interface |
BasicServlet.HttpContent
from Jetty HttpContent.java |
Field Summary | |
---|---|
protected I2PAppContext |
_context
|
protected Log |
_log
|
protected File |
_resourceBase
|
Constructor Summary | |
---|---|
BasicServlet()
|
Method Summary | |
---|---|
protected void |
addMimeMapping(String extension,
String type)
|
protected static String |
addPaths(String base,
String path)
Simple version of URIUtil.addPaths() |
protected static String |
decodePath(String path)
Simple version of URIUtil.decodePath() |
protected void |
doDelete(HttpServletRequest request,
HttpServletResponse response)
|
protected void |
doGet(HttpServletRequest request,
HttpServletResponse response)
|
protected void |
doOptions(HttpServletRequest request,
HttpServletResponse response)
|
protected void |
doPost(HttpServletRequest request,
HttpServletResponse response)
|
protected void |
doTrace(HttpServletRequest request,
HttpServletResponse response)
|
protected static String |
encodePath(String path)
Simple version of URIUtil.encodePath() |
BasicServlet.HttpContent |
getContent(String pathInContext)
get Resource to serve. |
protected String |
getMimeType(String filename)
Get the MIME type by filename extension. |
File |
getResource(String pathInContext)
get Resource to serve. |
void |
init(ServletConfig cfg)
|
protected void |
loadMimeMap(String resourcePath)
|
protected boolean |
passConditionalHeaders(HttpServletRequest request,
HttpServletResponse response,
BasicServlet.HttpContent content)
Check modification date headers. |
protected void |
sendData(HttpServletRequest request,
HttpServletResponse response,
BasicServlet.HttpContent content)
|
protected void |
setResourceBase(File base)
Files are served from here |
protected void |
setWarBase(String base)
Only paths starting with this in the path are served |
protected void |
writeHeaders(HttpServletResponse response,
BasicServlet.HttpContent content,
long count)
|
Methods inherited from class javax.servlet.http.HttpServlet |
---|
doHead, doPut, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
---|
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final transient I2PAppContext _context
protected final transient Log _log
protected File _resourceBase
Constructor Detail |
---|
public BasicServlet()
Method Detail |
---|
public void init(ServletConfig cfg) throws ServletException
init
in interface Servlet
init
in class GenericServlet
ServletException
protected void setResourceBase(File base) throws UnavailableException
UnavailableException
protected void setWarBase(String base)
public File getResource(String pathInContext)
pathInContext
- The path to find a resource for.
public BasicServlet.HttpContent getContent(String pathInContext)
pathInContext
- The path to find a resource for.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
doGet
in class HttpServlet
ServletException
IOException
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
doPost
in class HttpServlet
ServletException
IOException
protected void doTrace(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
doTrace
in class HttpServlet
ServletException
IOException
protected void doOptions(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
doOptions
in class HttpServlet
ServletException
IOException
protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
doDelete
in class HttpServlet
ServletException
IOException
protected boolean passConditionalHeaders(HttpServletRequest request, HttpServletResponse response, BasicServlet.HttpContent content) throws IOException
IOException
protected void sendData(HttpServletRequest request, HttpServletResponse response, BasicServlet.HttpContent content) throws IOException
IOException
protected void writeHeaders(HttpServletResponse response, BasicServlet.HttpContent content, long count) throws IOException
IOException
protected void loadMimeMap(String resourcePath)
resourcePath
- in the classpath, without ".properties" extensionprotected String getMimeType(String filename)
filename
- A file name
protected void addMimeMapping(String extension, String type)
protected static String addPaths(String base, String path)
path
- may be nullprotected static String decodePath(String path) throws MalformedURLException
MalformedURLException
protected static String encodePath(String path)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |