• We should now be fully online following an overnight outage. Apologies for any inconvenience, we do not expect there to be any further issues.

How to make your own web app as start page in Tomcat 5 ?

kmthien

Senior member
Oct 8, 2002
363
0
0
Hi,

I have installed Tomcat 5.0.11 ay /usr/local/tomcat5/ and I have made my own website at /usr/local/tomcat5/webapps/abc/index.jsp

When I entered www.abc.com, it always display the /usr/local/tomcat5/webapps/ROOT/index.jsp

How to change this so that everytime whenever I enter www.abc.com, it will go to /usr/local/tomcat5/webapps/abc/index.jsp ??
 

Softballslug

Senior member
Feb 22, 2000
397
0
0
You need to add a context for your project. Should look something like:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<CONTEXT <BR className="org.apache.catalina.core.StandardContext">crossContext="true"
reloadable="true"
mapperClass="org.apache.catalina.core.StandardContextMapper"
useNaming="true"
debug="0"
swallowOutput="false"
privileged="false"
displayName="AutoServiceStruts"
wrapperClass="org.apache.catalina.core.StandardWrapper"
docBase="C:\Tomcat 4.1\webapps\AutoService\Web Content"
cookies="true"
path="/AutoServiceStruts"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper">

<LOGGER <BR className="org.apache.catalina.logger.FileLogger">debug="0"
verbosity="1"
prefix="Struts_Data__Logs_"
directory="logs"
timestamp="true"
suffix=".txt" />

<PARAMETER <BR name="context.param.name">override="false"
value="context.param.value" />

<ENVIRONMENT <BR name="maxExemptions">override="true"
type="java.lang.Integer"
value="15" />

<RESOURCELINK <BR name="linkToGlobalResource">type="java.lang.Integer"
global="simpleValue" />
</CONTEXT>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++

The parts you want to modify are:

displayName="ABC Application"

docBase="/user/local/tomcat5/webapps/abc"

path="/ABC"


This is provided you have the DNS for www.abc.com pointing to your server properly. Once the request is picked up, Tomcat looks for index.jsp (make sure this is a welcome file inside your web.xml file) inside of the abc folder.

Best of Luck...
 

kmthien

Senior member
Oct 8, 2002
363
0
0
Hi Softballslug,

u mean I need to add the context inside /usr/local/tomcat5/conf/server.xml ??
The <BR inside CONTEXT <BR className="org.apache.catalina.core.StandardContext">crossContext="true"
is it a mistake ?
 

Softballslug

Senior member
Feb 22, 2000
397
0
0
Yes,

Put all of the following into server.xml after the last </Context> that you find. Restart Tomcat and you should be able to
enter http://localhost/ABC and your jsp should display:

<CONTEXT <BR className="org.apache.catalina.core.StandardContext">crossContext="true"
reloadable="true"
mapperClass="org.apache.catalina.core.StandardContextMapper"
useNaming="true"
debug="0"
swallowOutput="false"
privileged="false"
displayName="ABC Application"
wrapperClass="org.apache.catalina.core.StandardWrapper"
docBase="/user/local/tomcat5/webapps/abc"
cookies="true"
path="/ABC"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper">
<LOGGER <BR className="org.apache.catalina.logger.FileLogger">debug="0"
verbosity="1"
prefix="Struts_Data__Logs_"
directory="logs"
timestamp="true"
suffix=".txt" />
<PARAMETER <BR name="context.param.name">override="false"
value="context.param.value" />
<ENVIRONMENT <BR name="maxExemptions">override="true"
type="java.lang.Integer"
value="15" />
<RESOURCELINK <BR name="linkToGlobalResource">type="java.lang.Integer"
global="simpleValue" />
</CONTEXT>

 

kmthien

Senior member
Oct 8, 2002
363
0
0
Hi Softball,

the context u wrote is not working. I shutdown Tomcat then add-in the context u gave me into server.xml then I tried to start Tomcat again, Tomcat refuse to start ! How ?
 

Softballslug

Senior member
Feb 22, 2000
397
0
0
Originally posted by: kmthien
Hi Softballs, How about I want my /usr/local/tomcat5/webapps/abc/index.jsp to display when I hit www.abc.com ?? Thanks !

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
 

Softballslug

Senior member
Feb 22, 2000
397
0
0
Originally posted by: kmthien
Hi Softball, the context u wrote is not working. I shutdown Tomcat then add-in the context u gave me into server.xml then I tried to start Tomcat again, Tomcat refuse to start ! How ?

That is usually due to a classpath exception being thrown. Remove the context that you added from the server.xml. Inside the good server.xml find a context and modify the params to make it look like the one I gave you.
 

Softballslug

Senior member
Feb 22, 2000
397
0
0
When Tomcat doesn't load properly use XML spy or something similar to verify that server.xml is well formed. Here is a better context. If you notice within the first context, I somehow got <BR in places??? Don't quite know how I did that but that is the problem:

<Context className="org.apache.catalina.core.StandardContext" crossContext="true" reloadable="true"
mapperClass="org.apache.catalina.core.StandardContextMapper" useNaming="true" debug="0"
swallowOutput="false" privileged="false" displayName="ABC"
wrapperClass="org.apache.catalina.core.StandardWrapper" docBase="/user/local/tomcat5/webapps/abc"
cookies="true" path="/ABC" cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper">
<Logger className="org.apache.catalina.logger.FileLogger" debug="0" verbosity="1"
prefix="ABC_Logs_" directory="logs" timestamp="true" suffix=".txt"/>
<Parameter name="context.param.name" override="false" value="context.param.value"/>
<Environment name="maxExemptions" override="true" type="java.lang.Integer" value="15"/>
<ResourceLink name="linkToGlobalResource" type="java.lang.Integer" global="simpleValue"/>
</Context>