Two web applications on the same domain with different context roots?

I have a problem. I have two web applications deployed as wars. Name them app1.war and app2.war .

I would like for app1.war be available at the URL www.website.com , and I would like for app2.war be available as www.website.com/anotherapp . I have my domain name.

Shared hosting doesn't seem to help here.

I am running JBoss App Server 5.1 and Seam 2.2.0. I am working on integrating a forum (deployed as a war) with my application (deployed as another war), and therefore I need to use single sign-on and therefore would like the URL formats described above to make sso file transfer easier.

Thanks for any ideas.

-Charles.

+6
dns jboss seam single-sign-on
source share
4 answers

You need to do things like this:

  • Configure JBoss to use a virtual host named www.website.com.

    You can do this by editing server.xml from jbossweb.sar . In short, you need to configure another Host directive.

  • You need to set up a military application. You can do this by creating or editing the jboss-web.xml (it should be placed in the WEB-INF ). In this file you can configure which virtual host should be used and in what context.

Example of this file for app1.war

 <jboss-web> <context-root>/</context-root> <virtual-host>website</virtual-host> </jboss-web> 

Example of this file for app2.war

 <jboss-web> <context-root>/anotherapp</context-root> <virtual-host>website</virtual-host> </jboss-web> 

You can find more information in this post. Hosting multiple domains with JBoss

+4
source share

Did not use JBoss at that time or Seam, but if it is similar to most application servers, there will be an XML file of some description in which you map URL patterns to applications. Check the docs for details, but I think you want to use web.xml and a few servlet entries, for example:

 <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.seam</url-pattern> </servlet-mapping> 

Change the URL and servlets accordingly.

+1
source share

I would like for app1.war to be available at the following URL: www.website.com, and I would like for app2.war to be available as www.website.com/anotherapp. Of course I have my domain name.

The easiest way to achieve your specific use case is to deploy app1.war to ROOT.war and app2.war in anotherapp.war in the / deploy directory. This works best when you use a blasted combat deployment.

If you do not want to rename your exploded military folders, you can use symbolic binding.

+1
source share

To have the same cookie for all web applications in the servlet container, add a SessionCookie to deploy /jbossweb.sar/context.xml:

 <Context> ... <SessionCookie path="/" /> </Context> 

If you do not want to rename ROOT.war to another, and let app1.war get the ROOT.war name (I don’t understand why not), you can probably do apache redirect / rewrite / proxy to hide the root of the real application context 1

+1
source share

All Articles