Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mortbay.servlet
Class ConcatServlet

    java.lang.Object
      javax.servlet.GenericServlet
          javax.servlet.http.HttpServlet
              org.mortbay.servlet.ConcatServlet

All Implemented Interfaces:
  java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

    public class ConcatServlet

extends javax.servlet.http.HttpServlet

Concatenation Servlet This servlet may be used to concatenate multiple resources into a single response. It is intended to be used to load multiple javascript or css files, but may be used for any content of the same mime type that can be meaningfully concatenated.

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.

Author:
  gregw
See Also:
  Serialized Form

Constructor Summary
`ConcatServlet()`

Method Summary
`protected void` | `doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)`
`protected long` | `getLastModified(javax.servlet.http.HttpServletRequest req)`
`void` | `init()`

Methods inherited from class javax.servlet.http.HttpServlet
`doDelete, doHead, doOptions, doPost, doPut, doTrace, 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`

Constructor Detail

### ConcatServlet

    public ConcatServlet()

Method Detail

### init

    public void init()
              throws javax.servlet.ServletException

  Overrides:
    `init` in class `javax.servlet.GenericServlet`
  Throws:
    `javax.servlet.ServletException`

### getLastModified

    protected long getLastModified(javax.servlet.http.HttpServletRequest req)

  Overrides:
    `getLastModified` in class `javax.servlet.http.HttpServlet`

### doGet

    protected void doGet(javax.servlet.http.HttpServletRequest req,
                         javax.servlet.http.HttpServletResponse resp)
                  throws javax.servlet.ServletException,
                         java.io.IOException

  Overrides:
    `doGet` in class `javax.servlet.http.HttpServlet`
  Throws:
    `javax.servlet.ServletException`
    `java.io.IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.