User Tools

Site Tools


java:staticminisiteinjboss

How to create a directory to serve only static content in Jboss

For Jboss 7

Under Jboss 7, things have changed in this issue: Jboss AS 7 enforces the deployment with archive files (.war, .ear and so on) instead of cut-and-paste of the filesystem in the deployment directory.

For achieveing the same goal, the only thing you have to do is:

1. let's suppose you have a directory called “myApp” with three webpages: index.html, first.html and second.html:

myApp
  |
  +--- index.html
  |
  +--- first.html
  |
  +--- second.html

2. you have to select the three elements and select “save as a zip file”: then the three files will be saved in a zip file called something like “index.zip”. 3. rename the file to “myApp.war” (to do this you probably have to set the extensions of your windows as “visible”). 4. and that's it, you have a war file ready to deploy into your jboss.

Yes, but I want also to deploy this application as the default application of the server

You only have to include a jboss-web.xml file with this content:

<jboss-web>
    <context-root>/</context-root>
</jboss-web>

It is probable that many applications would fight for the root position of your web server and this will result in crashes, be careful with this.

http://docs.jboss.org/jbossas/guides/webguide/r2/en/html/ch06.html

For Jboss 5 and previous releases

Let's say that you want to create a url like http://localhost:8080/doc to serve only static content. How it is done???

Here are instructions:

  • Create a directory JBOSS_HOME/server/xxx/deploy/doc.war. The “.war” is very important.
  • Under this directory, create a directory WEB-INF and inside this directory a file called web.xml
  • The content of the file web.xml will be:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
 xmlns="http://java.sun.com/xml/ns/j2ee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 
 
 <display-name>Documentation</display-name>
 
 <welcome-file-list>
  <welcome-file>index.html</welcome-file>
 </welcome-file-list>
 
</web-app>
java/staticminisiteinjboss.txt · Last modified: 2014/12/24 10:42 (external edit)