public class ConcatServlet extends HttpServlet
The servlet uses RequestDispatcher.include(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
to combine the requested content, so dynamically generated content
may be combined (Eg engine.js for DWR).
The servlet uses parameter names of the query string as resource names relative to the context root. So these script tags:
<script type="text/javascript" src="../js/behaviour.js"></script> <script type="text/javascript" src="../js/ajax.js&/chat/chat.js"></script> <script type="text/javascript" src="../chat/chat.js"></script>can be replaced with the single tag (with the ConcatServlet mapped to /concat):
<script type="text/javascript" src="../concat?/js/behaviour.js&/js/ajax.js&/chat/chat.js"></script>The
ServletContext.getMimeType(String)
method is used to determine the
mime type of each resource. If the types of all resources do not match, then a 415
UNSUPPORTED_MEDIA_TYPE error is returned.
If the init parameter "development" is set to "true" then the servlet will run in development mode and the content will be concatenated on every request. Otherwise the init time of the servlet is used as the lastModifiedTime of the combined content and If-Modified-Since requests are handled with 206 NOT Modified responses if appropriate. This means that when not in development mode, the servlet must be restarted before changed content will be served.
Constructor and Description |
---|
ConcatServlet() |
Modifier and Type | Method and Description |
---|---|
protected void |
doGet(HttpServletRequest req,
HttpServletResponse resp) |
protected long |
getLastModified(HttpServletRequest req) |
void |
init() |
doDelete, doHead, doOptions, doPost, doPut, doTrace, service, service
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
public void init() throws ServletException
init
in class GenericServlet
ServletException
protected long getLastModified(HttpServletRequest req)
getLastModified
in class HttpServlet
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
doGet
in class HttpServlet
ServletException
IOException
Copyright © 1995-2015 Webtide. All Rights Reserved.