aspose file tools*
The moose likes Beginning Java and the fly likes Tomcat Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Tomcat Question" Watch "Tomcat Question" New topic
Author

Tomcat Question

Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 742
I have three websites but I can work with one website at a time to put it in ROOT.

Can I view three different websites with tomcat without copy pasting them in ROOT?

Thanks & best regards
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42913
    
  68
I wouldn't put anything into ROOT. Why don't you keep the three sites in 3 (non-ROOT) subdirectories of the webapps directory; all 3 can run in parallel that way. The URL would be http://localhost:8080/myApp1/ instead of http://localhost:8080/ in that case, but all links should work the same, assuming you're using relative links.
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1836
    
    7

You can run multiple web applications simultatiously by adding them to their own context like so:

%CATALINA_HOME%/webapps/webapp1
%CATALINA_HOME%/webapps/webapp2
%CATALINA_HOME%/webapps/webapp3
etc.

Where webappN would contain the typical web application directory structure. Or by just adding web application archives (.WAR) to %CATALINA_HOME%/webapps/ and having Tomcat explode them for you during deployment. Why would you want to add your web application files to the ROOT context?

Edit: Aw, too slow. Ulf beat me to it
[ March 27, 2008: Message edited by: Jelle Klap ]

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 742
Originally posted by Ulf Dittmer:
I wouldn't put anything into ROOT. Why don't you keep the three sites in 3 (non-ROOT) subdirectories of the webapps directory; all 3 can run in parallel that way. The URL would be http://localhost:8080/myApp1/ instead of http://localhost:8080/ in that case, but all links should work the same, assuming you're using relative links.


No, not working. I have aa folder and inside aa is company==>>profile.html
http://localhost:8080/aa is working but when am clicking the link the following message appears. Can I have to make changes in tomcat ?

HTTP Status 404 - /company/profile.html

--------------------------------------------------------------------------------

type Status report

message /company/profile.html

description The requested resource (/company/profile.html) is not available.
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 742
%CATALINA_HOME%/webapps/webapp1
%CATALINA_HOME%/webapps/webapp2
%CATALINA_HOME%/webapps/webapp3

Thanks for your help.

I am very new to tomcat and Java. where can I see .war file or where I make recommended changes

Thanks again
[ March 27, 2008: Message edited by: Farakhkhan ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

In order for Tomcat to see a folder (under webapps) as an application, that folder must have a WEB-INF folder inside it.

tomcat/webapps/aa/WEB-INF


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 742
Originally posted by Ben Souther:
In order for Tomcat to see a folder (under webapps) as an application, that folder must have a WEB-INF folder inside it.

tomcat/webapps/aa/WEB-INF


Yes that has WEB-INF folder and web.xml but still am facing the problems. What else could be changed

Thanks & best regards
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"Raakh",
Please check your private messages regarding an important administrative matter.
-Ben
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"Farakhkhan",
Please check your private messages regarding an important administrative matter.
-Ben
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 742
Originally posted by Ben Souther:
"Farakhkhan",
Please check your private messages regarding an important administrative matter.
-Ben


I checked and send you 2 simultaneous messages

Can anybody please help/guide me regarding my tomcat question?

thanks & best regards
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Farakhkhan:


I checked and send you 2 simultaneous messages

Can anybody please help/guide me regarding my tomcat question?

thanks & best regards


Please check them again.
-Ben
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 742
Originally posted by Ben Souther:


Please check them again.
-Ben


Is it ok Now?
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1836
    
    7

Ok, a very simple example:

1. Create a folder called helloworld in %CATALINA_HOME%/webapps, where %CATALINA_HOME% is the Tomcat installation folder.

2. Create a new plain text file with the following contents:


3. Save this file as index.html in %CATALINA_HOME%/webapps/helloworld

4. Start Tomcat (if not running).

5. Start a webbrowser and navigate to http://localhost:8080/helloworld (assuming localhost is the listen adress and 8080 is the listen port).

You should see the hello world message.
[ March 27, 2008: Message edited by: Jelle Klap ]
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 742
Its mean that when I'll use the path of other file then I have to follow the path of this folder e.g. aa==>>index.html, company folder===>>profile.html like this /aa/company/profile.html whereas I was using in ROOT just: /company/profile.html

right?

Thanks & best regards
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Jelle Klap:
3. Save this file as index.html in %CATALINA_HOME%/webapps/helloworld.


Again, Tomcat (in versions up to 5.5 anyway) won't recognize a folder as a web application unless it contains a WEB-INF folder.
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1836
    
    7

Originally posted by Ben Souther:


Again, Tomcat (in versions up to 5.5 anyway) won't recognize a folder as a web application unless it contains a WEB-INF folder.


It's fairly reasonable to assume that somebody just starting to learn about Tomcat downloaded a recent version to do so, and I didn't want to complicate things unnecessarily.
[ March 27, 2008: Message edited by: Jelle Klap ]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by farakh khan:


No, not working. I have aa folder and inside aa is company==>>profile.html
http://localhost:8080/aa is working but when am clicking the link the following message appears. Can I have to make changes in tomcat ?

HTTP Status 404 - /company/profile.html

--------------------------------------------------------------------------------

type Status report

message /company/profile.html

description The requested resource (/company/profile.html) is not available.


You should probably use a relative URL in that link (one that doesn't start with a slash).


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat Question