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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tomcat w/ different connector

Status
Not open for further replies.

yytan

Programmer
May 8, 2002
113
MY
hi here;
i am doing a normal (testing) java web app. currently i am running tomcat4.1 on linux. i have change the port from 8080 to 8888 and i am using context path to point to the source (jsp file) directory.

so, the port 8080 will have a context path look like this:


<Context path="/jsp" docBase="/home/swx/jspAdm" debug="0"
reloadable="true" crossContext="true"/>

so the connection url to point to it will be
http:ip:8888/jsp/login.jsp

my question now is, i have put another version (slightly change the content of jsp) in the dir "/home/csb/jspAdm" is it possible if i want to access it like this

http:ip:7777/jsp/login.jsp

how do i conf in my server.xml???
 
Don't you mean the connection url will be

http:ip:8080/jsp/login.jsp?

If so, just change '8080' to '7777'

Now, if you want to have BOTH available to do the same thing just add another connector on the proper port.

I may not be understanding what your overall goal is, this snapshot of intention doesn't tell much.
 
There are two ways to do this as far as I know :

1) Install tomcat in two different locations, alter ALL the ports used in server.xml (eg not only the listening http port, but also the internal service port - 8009), and then run the two installs.

2) Use the <Host> section in server.xml to set up multiple virtual hosts. Eg :
Code:
        <Host name="[URL unfurl="true"]www.test.com"[/URL] debug="0" appBase="webapps"
         unpackWARs="true" autoDeploy="true"
         xmlValidation="false" xmlNamespaceAware="false">

...
...
...
          <Context path="" docBase="test" debug="0"
                   reloadable="true" crossContext="true">
...
...
...

        <Host name="[URL unfurl="true"]www.development.com"[/URL] debug="0" appBase="webapps"
         unpackWARs="true" autoDeploy="true"
         xmlValidation="false" xmlNamespaceAware="false">

...
...
...
          <Context path="" docBase="development" debug="0"
                   reloadable="true" crossContext="true">
...
...
...
The if you put your two webapps in the webapps directory, one under the "test" directory and the other in the "development" directory, you will be able to access each like this :


You will need to also change your host file for your PC so that the two URLs point to your server.
 
Dear Sedj;

i will try out now, 10s for the great suggestion ;)

rgd/ yoke yew
 
Dear Sedj;

i have try ur method, just added a new <HostName...>

but it return Invalid Page?

pls advice, 10s ;)

rgd/ yoke yew
 
Invalid Page ? Do you mean it throws a 404 error, a 500 error or returns successfully with a page you were not expecting ?

Post your the relevant section of server.xml ...

--------------------------------------------------
Free Database Connection Pooling Software
 
hi Sedj;

even i change <localhost to yytan>

i also cant view thru


my server.xml

<div>

<!-- Define the default virtual host -->
<Host name="yytan" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true">

<!-- Logger shared by all Contexts related to this virtual host. By
default (when using FileLogger), log files are created in the "logs"
directory relative to $CATALINA_HOME. If you wish, you can specify
a different directory with the "directory" attribute. Specify either a
relative (to $CATALINA_HOME) or absolute path to the desired
directory.-->
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>

<!-- Tomcat Root Context -->
<!--
<Context path="" docBase="ROOT" debug="0"/>
-->

<!-- Web Admin Module -->

<Context path="/swx" docBase="/home/swx/servlets" debug="0"
reloadable="true" crossContext="true"/>
<Context path="/jsp" docBase="/home/swx/jspAdm" debug="0"
reloadable="true" crossContext="true"/>

<Context path="/swx1" docBase="/home/swxcsb/servlets" debug="0"
reloadable="true" crossContext="true"/>
<Context path="/jsp1" docBase="/home/swxcsb/jspAdm" debug="0"
reloadable="true" crossContext="true"/>

<!-- Tomcat Examples Context -->
<Context path="/examples" docBase="examples" debug="0"
reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_examples_log." suffix=".txt"
timestamp="true"/>
<Ejb name="ejb/EmplRecord" type="Entity"
home="com.wombat.empl.EmployeeRecordHome"
remote="com.wombat.empl.EmployeeRecord"/>

</div>
 
Hi Sedj;

even i have try to remain the original <Host to "localhost">...

and i tried to append

<Host name=" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">

before the <Context path="/swx1"

i tried to access by


it said " The page cannot be displayed"
 
Dear Sedj / all;

pls help me to verify my server.xml

10s ;)
 
If you had a context named "myWebApp" in TOMCAT_HOME/webapps/myWebApp

which had a file called index.html at :

TOMCAT_HOME/webapps/myWebApp/index.html

and accessed it via this url :


then you web.xml should look like

<Host name=" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true">

<!-- Logger shared by all Contexts related to this virtual host. By
default (when using FileLogger), log files are created in the "logs"
directory relative to $CATALINA_HOME. If you wish, you can specify
a different directory with the "directory" attribute. Specify either a
relative (to $CATALINA_HOME) or absolute path to the desired
directory.-->
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>

<Context path="" docBase="myWebApp" debug="0"
reloadable="true" crossContext="true"/>
</Host>

--------------------------------------------------
Free Database Connection Pooling Software
 
Dear Sedj;

1) - error w/ The page cannot be found

2) i didnt put the project sit under TOMCAT_HOME/webapps/
it located at /home/swx/jspAdm

3) do i needto update my
- server.xml or
- web.xml (u mentioned is web.xml in ur prev mail)

really appreciate for ur good help ;)

rgd/ yoke yew
 
1) Did you create a "index.html" as a test ?
2)I know your doc source is somewhere else, but for now, just follow my suggestion to get this example working - once you know how it works in the simplest form, you can yourself play around with different directory locations - but for now, just create the following :

create directories :

TOMCAT_HOME/webapps/myWebApp
TOMCAT_HOME/webapps/myWebApp/WEB-INF

create an index.html file, just with "Hello" or something simple in it, and place it in : TOMCAT_HOME/webapps/myWebApp

Edit your server.xml file to include :

<Host name=" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true">

<!-- Logger shared by all Contexts related to this virtual host. By
default (when using FileLogger), log files are created in the "logs"
directory relative to $CATALINA_HOME. If you wish, you can specify
a different directory with the "directory" attribute. Specify either a
relative (to $CATALINA_HOME) or absolute path to the desired
directory.-->
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>

<Context path="" docBase="myWebApp" debug="0"
reloadable="true" crossContext="true"/>
</Host>

Then access :


I realise this is not how your final setup will be - but please follow these instructions carefully as a test OK !

--------------------------------------------------
Free Database Connection Pooling Software
 
Dear Sedj;

i will follow ur example.

10s ;)

rgd/ yoke yew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top