Two Laptop Bag*
The moose likes Tomcat and the fly likes tomcat and web pages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "tomcat and web pages" Watch "tomcat and web pages" New topic
Author

tomcat and web pages

miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
in my winXP i've apache 2 and tomcat5; i can run a website from home using apache2.
My question is: how can i run a website using tomcat? (i tried typing :8080 at the end but without result)

TiA


java amateur
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Yes, but you've got to make sure everything is configured correctly. Have you read the relevant Tomcat docs?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
i gave it a look and, besides not understanding it well enough, i learned i was suposed to have a war file, so now my war is learning how to make one
p.s. hope i dont get a third rtfm within the very same day ;)
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

A war file is just a way to package a web application.
I would concern myself with getting Tomcat up and running before worrying about war files.

Tomcat ships with several applications that are ready to go as soon as you get the server running.


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

Joined: Feb 08, 2004
Posts: 1281
Tomcat ships with several applications that are ready to go as soon as you get the server running.

but that i have!, and i've tested my jsp's and servlets quite well; i thought i could "see" those pages over the internet the way i do with my apache that serves php files
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
here i go again
i followed this tutorial, created the war file and tomcat works fine with it (appears in its list applications)
what keeps puzzling me is this: if i enter this url:
http://localhost:8080/onjava/login.jsp
i get the page, but if instead of localhost i type my ip, i cant get it

here's what i read from tomcat docs:
Deployment With Tomcat 5
In order to be executed, a web application must be deployed on a servlet container. This is true even during development. We will describe using Tomcat 5 to provide the execution environment. A web application can be deployed in Tomcat by one of the following approaches:

Copy unpacked directory hierarchy into a subdirectory in directory $CATALINA_HOME/webapps/. Tomcat will assign a context path to your application based on the subdirectory name you choose. We will use this technique in the build.xml file that we construct, because it is the quickest and easiest approach during development. Be sure to restart Tomcat after installing or updating your application.

==> what i did <==
Copy the web application archive file into directory $CATALINA_HOME/webapps/. When Tomcat is started, it will automatically expand the web application archive file into its unpacked form, and execute the application that way. This approach would typically be used to install an additional application, provided by a third party vendor or by your internal development staff, into an existing Tomcat installation. NOTE - If you use this approach, and wish to update your application later, you must both replace the web application archive file AND delete the expanded directory that Tomcat created, and then restart Tomcat, in order to reflect your changes.

==> tried this too <==
Use the Tomcat 5 "Manager" web application to deploy and undeploy web applications. Tomcat 5 includes a web application, deployed by default on context path /manager, that allows you to deploy and undeploy applications on a running Tomcat server without restarting it. See the administrator documentation (TODO: hyperlink) for more information on using the Manager web application.
(...)



what am i doing wrong?

TiA
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

You don't need to create a war file. That is a just a convenient way to transport and deploy a web app. Don't worry about war files now (and maybe not ever).

Lay your web app properly on disk and create the Context entry that points to it before doing anything else.
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
i guess i did that already: in conf/server.xml, i added:
<Context path="/onjava" docBase="onjava" debug="0" reloadable="true" />
i tried also:
<Context path="/onjava.war" docBase="onjava.war" debug="0" reloadable="true" /> and both work with localhost only
(last one only after i remove onjava folder)
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by miguel lisboa:

what keeps puzzling me is this: if i enter this url:
http://localhost:8080/onjava/login.jsp
i get the page, but if instead of localhost i type my ip, i cant get it


If you can see it with localhost, then Tomcat is running and your app is deployed correctly.

If you're having problems seeing it with an IP, it's not a Tomcat problem.
Is port 8080 open to outside traffic on your network?
Are you running a firewall on that machine that is restricting access to port 8080 (maybe only allowing local host to access it?).

Again, it sounds like Tomcat and your app are both fine.
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
Is port 8080 open to outside traffic on your network?

bingo!
thanks a lot to everyone who tried to help me out
i forgot about my router
[ November 10, 2006: Message edited by: miguel lisboa ]
 
 
subject: tomcat and web pages