Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple contexts on single domain

Status
Not open for further replies.

rudejohn

IS-IT--Management
Jul 11, 2003
130
US
Hello everyone... been awhile since I've been on... sorry for not lurking and helping out but my job switched to a non-technical job (temporarily). Oh well.

I'm currently trying to combine 2 distinct web application into 1 application. And, I'm trying to figure out a clever way to account for the minor differences (i.e. Cascading Style sheats, and a few message banners).

I thought about using structs MessageResources to account for the differences between the two sites. To do this, I overrode the processLocale() method in the RequestProcessor and modified the Locale based on the domain specified in the url (i.e. Site1-eng_AM and Site2-eng_AM) However, because we will have a single domain this will no longer work.

Furthermore, because a single web application can only have 1 context path, I can't use it either.

My team is thinking about just having 2 copies of the same code in 2 directories so that the url will be and but that could cause maintanence headaches in the future.

Does anyone have any clever suggestions for having a single web application that can account for minor differences?

I realize this is a very specific and tough question. An entire box of cookies to those who can offer help.

TIA,

RJ


************
RudeJohn
************
 
Using Struts modules you can have two different prefix (context) for your application, i.e. two sites with one web application.

By defining two modules for your application, each module has it own URL prefix and struts-config file.

Code:
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
   <!-- module 1 -->
   <param-name>config/site1</param-name>
   <param-value>/WEB-INF/conf/struts-site1-config.xml</param-value>
</init-param>
<init-param>
   <!-- module 2 -->
   <param-name>config/site2</param-name>
   <param-value>/WEB-INF/conf/struts-site2-config.xml</param-value>
</init-param>
....
then:
with URL ..../site1/index.do will use struts-site1-config.xml

and URL ..../site2/index.do will use struts-site2-config.xml

each site/module can have their only resource file defined in their respective struts-config file.

e.g. in struts-site1-config.xml you can have a resource file
<message-resources parameter="test.struts.site1-ApplicationResources" />

and in site2 you canhave a different resource file
<message-resources parameter="test.struts.site2-ApplicationResources" />

Also, by extending your own ActionMapping class, you can define new properties for action mapping. Say a property to set css for different page/site. The property value can then be retrieve in its respective Action class. With addition of css property, in the action mapping, you can do something like:

Code:
<action path="/index.do" type="test.struts.action.HomePage">
   <forward name="success" path="/index.jsp" />
   <set-property property="css" value= "site.css" />
</action>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top