Class StaticResourceServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- de.businesscode.bcdui.web.servlets.StaticResourceServlet
-
- All Implemented Interfaces:
java.io.Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
public class StaticResourceServlet extends javax.servlet.http.HttpServlet
This class enables the use of the database-backed virtual file system and jar files as source for seemingly static resources. Normal static files are located on the filesystem within the webapps root, put there when the server extracts the app.war file. Static files are requested by /appContext/some/path/someFile.txt for example. This class makes files under such an address available, which really come from the database or a jar (and classpath in general) within the app.war instead. Main usage is the virtual file system and making BCD-UI static files like js and xslt available from bcd-ui-core.jar within app.war. The search order is: First vfs, then file system (on server this is normal file from the war), then jar files. Note: Since vfs caches the file list from the database (not the actual content), a lookup in vfs is no performance hit.<servlet> <servlet-name>staticResourceServlet</servlet-name> <servlet-class>de.businesscode.web.StaticResourceServlet</servlet-class> <init-param> <param-name>vfsFileExtensions</param-name> <!-- Extensions that can be overwritten in vfs --> <param-value>xml txt vfsxml pdf png gif jpg jpeg svg doc docx xls xlsx csv zip</param-value> </init-param> </servlet> <!-- Add any URL for the virtual file system here --> <servlet-mapping> <servlet-name>bcdui4.StaticResourceServlet</servlet-name> <url-pattern>/bcdui/*</url-pattern> <url-pattern>/vfs/*</url-pattern> <url-pattern>*.vfsxml</url-pattern> </servlet-mapping>
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StaticResourceServlet.LocalResource
This class represents one single resource which is either a file on the file system or a URL from the classpath.static interface
StaticResourceServlet.Resource
resource abstract descriptor implementing API to the contentstatic interface
StaticResourceServlet.ResourceProvider
provider interface to resolve aStaticResourceServlet.Resource
static class
StaticResourceServlet.StaticResourceProvider
a static resource provider singleton
-
Constructor Summary
Constructors Constructor Description StaticResourceServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
Implementation of GET requests.protected void
doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
void
init(javax.servlet.ServletConfig config)
-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
-
-
-
-
Method Detail
-
init
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
- Specified by:
init
in interfacejavax.servlet.Servlet
- Overrides:
init
in classjavax.servlet.GenericServlet
- Throws:
javax.servlet.ServletException
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, java.io.IOException
Implementation of GET requests.- Overrides:
doGet
in classjavax.servlet.http.HttpServlet
- Throws:
javax.servlet.ServletException
java.io.IOException
-
doPost
protected void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, java.io.IOException
- Overrides:
doPost
in classjavax.servlet.http.HttpServlet
- Throws:
javax.servlet.ServletException
java.io.IOException
-
-