Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ul> <li>Option 1: You could try to deploy a <strong>separate exploded .war file</strong>, and use that for your static content</li> </ul> <p>In your case: In <code>.../jboss-7/standalone/deployments/</code> there must be a <code>static.war/</code>.</p> <p>So the uploads go into this directory, and the content is served back the normal way.</p> <p>As for details, see <a href="https://stackoverflow.com/q/14368629/2390083">Is it possible to deploy an exploded war file (unzipped war) in JBoss AS 7</a></p> <p>As pointed out by BalusC: You must not redeploy/remove this directory, as soon as data has been uploaded. You should have a regular backup of this directory.</p> <p>As far as I know this is the only possibility to do it <strong>by configuration/setup only</strong>.</p> <hr> <ul> <li>Option 2: Create separate webapp with name <code>static.war</code>. Add a <strong>servlet to stream the static content</strong></li> </ul> <p>This way there is no need to upload/store the files into the file system below <code>../deployments/</code>, it could be any directory, but you need an additional servlet, so it's solved programatically.</p> <p>A simple streaming servlet could look like this (just streaming - no authentication etc.):</p> <pre><code>public class DownloadServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final File dir = new File("/var/cms/storage/"); final String start = "/static/"; final String relativePath = request.getRequestURI().substring( request.getRequestURI().indexOf(start) + start.length()); final File file = new File(dir, relativePath); final String ct = URLConnection.guessContentTypeFromName(file.getName()); response.setContentType(ct); final InputStream is = new BufferedInputStream(new FileInputStream(file)); try { final boolean closeOs = true; org.apache.commons.fileupload.util.Streams.copy (is, response.getOutputStream(), closeOs); } finally { is.close(); } } </code></pre> <p>Map all URLs to this servlet:</p> <pre class="lang-xml prettyprint-override"><code>&lt;servlet-mapping&gt; &lt;servlet-name&gt;DownloadServlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; </code></pre> <p>The name <code>static.war</code> provides the <code>/static/</code> web context, so that should make it compatible with the URLs in your code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload