Friday, August 12, 2011

Multi Context URL Configuration

Multi Context URL Configuration
--------------------------------------------
1. Overview Multi Context URL Configuration

Web server allows configuring multiple contexts URL. Tomcat also allows configuring multiple URL configurations for single application i.e. multiple URL points to the same war file or application directory. It is web server configuration process. For multiple URL configurations for single application need to provide configuration details in server configuration file.

In this document trying to explain how to access WSTransalationService application using two URL /activation and /WSTranslationService.

2. Tomcat Configuration

Tomcat server configuration file name server.xml. Provide context details in tomcat configuration file. If any configuration is not available in tomcat then it offers the application war file name or application directory name as the application context to access the application.

As example if application war file name or application name “WSTransalationService” then that application URL like http://<serverName>:<port>/WSTransalationService. Application name and URL both will be same by default [note: URL case sensitive].

2.1. Context Details
 Context syntax
<context source="org.eclipse.jst.jee.server:WSTransalationService" reloadable="true" path="URL" docbase="war file path">

 Context example
<context source="org.eclipse.jst.jee.server:WSTransalationService" reloadable="true" path="/WSTransalationService" docbase="C:\apache-tomcat-6.0.29\webapps\WSTransalationService">

2.2. Tomcat Configuration
 Open server.xml file : go to tomcat installation directory => conf =>server.xml

 Add context details in side <host>tag for URL configuration for /activation and /WSTransalationService.

<host name="localhost" appbase="webapps" autodeploy="true" unpackwars="true" xmlnamespaceaware="false" xmlvalidation="false">

<context source="org.eclipse.jst.jee.server:WSTransalationService" reloadable="true" path="/activation" docbase="C:\apache-tomcat-6.0.29\webapps\WSTransalationService">

<context source="org.eclipse.jst.jee.server:WSTransalationService" reloadable="true" path="/WSTransalationService" docbase="C:\apache-tomcat-6.0.29\webapps\WSTransalationService">

</host>


 Start tomcat server and send request.
2.3. Application in Tomcat Admin portal
Two application instances will be create in tomcat virtually. Tomcat admin portal display two URL and instance details. /activation and /WSTransalationService application instance will be visible in tomcat admin portal.



2.4. Access Application with multiple URL
 Open browser and send URL: http://localhost:8080/WSTransalationService/ or https://localhost:443/WSTransalationService/



 Open browser and send URL: http://localhost:8080/activation/ or https://localhost:443/activation/




No comments:

Post a Comment