Class FileServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.openremote.container.web.file.AbstractFileServlet
org.openremote.container.web.file.FileServlet
- All Implemented Interfaces:
Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.openremote.container.web.file.AbstractFileServlet
AbstractFileServlet.Range, AbstractFileServlet.RedirectException, AbstractFileServlet.Resource -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetContentType(javax.servlet.http.HttpServletRequest request, File file) Returns the content type associated with the given HTTP servlet request and file.protected longgetExpireTime(javax.servlet.http.HttpServletRequest request, File file) Returns how long the resource may be cached by the client before it expires, in seconds.protected StringgetExtension(String fileName) protected FilegetFile(javax.servlet.http.HttpServletRequest request) Returns the file associated with the given HTTP servlet request.booleanprotected voidservice(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) protected StringsetContentHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, AbstractFileServlet.Resource resource, List<AbstractFileServlet.Range> ranges) Set content headers.Methods inherited from class org.openremote.container.web.file.AbstractFileServlet
coalesce, doGet, doHead, encodeURI, encodeURL, handleFileNotFound, setCacheHeaders, setNoCacheHeaders, startsWithOneOf, stream, streamMethods inherited from class javax.servlet.http.HttpServlet
doDelete, doOptions, doPost, doPut, doTrace, getLastModified, serviceMethods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
-
Field Details
-
DEFAULT_EXPIRE_SECONDS
public static final long DEFAULT_EXPIRE_SECONDS- See Also:
-
EXPIRES_SECONDS_CACHE_JS
public static final long EXPIRES_SECONDS_CACHE_JS- See Also:
-
devMode
protected final boolean devMode -
base
-
unsecuredIndex
-
requiredRoles
-
mimeTypes
-
mimeTypesExpireSeconds
-
alreadyZippedExtensions
-
-
Constructor Details
-
FileServlet
-
-
Method Details
-
isSecured
public boolean isSecured() -
service
protected void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException - Overrides:
servicein classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
getFile
protected File getFile(javax.servlet.http.HttpServletRequest request) throws AbstractFileServlet.RedirectException Description copied from class:AbstractFileServletReturns the file associated with the given HTTP servlet request. If this method throwsIllegalArgumentException, then the servlet will return a HTTP 400 error. If this method returnsnull, or ifFile.isFile()returnsfalse, then the servlet will invokeAbstractFileServlet.handleFileNotFound(HttpServletRequest, HttpServletResponse).- Specified by:
getFilein classAbstractFileServlet- Parameters:
request- The involved HTTP servlet request.- Returns:
- The file associated with the given HTTP servlet request.
- Throws:
AbstractFileServlet.RedirectException
-
getExpireTime
Description copied from class:AbstractFileServletReturns how long the resource may be cached by the client before it expires, in seconds.The default implementation returns 30 days in seconds.
- Overrides:
getExpireTimein classAbstractFileServlet- Parameters:
request- The involved HTTP servlet request.file- The involved file.- Returns:
- The client cache expire time in seconds (not milliseconds!).
-
getContentType
Description copied from class:AbstractFileServletReturns the content type associated with the given HTTP servlet request and file.The default implementation delegates
File.getName()toServletContext.getMimeType(String)with a fallback default value ofapplication/octet-stream.- Overrides:
getContentTypein classAbstractFileServlet- Parameters:
request- The involved HTTP servlet request.file- The involved file.- Returns:
- The content type associated with the given HTTP servlet request and file.
-
setContentHeaders
protected String setContentHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, AbstractFileServlet.Resource resource, List<AbstractFileServlet.Range> ranges) Description copied from class:AbstractFileServletSet content headers.- Overrides:
setContentHeadersin classAbstractFileServlet
-
getExtension
-