This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Tomcat and the fly likes tomcat execution problem and other thing 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 » Products » Tomcat
Bookmark "tomcat execution problem and other thing" Watch "tomcat execution problem and other thing" New topic
Author

tomcat execution problem and other thing

oussama jlassi
Greenhorn

Joined: Dec 23, 2011
Posts: 25
hi there
when i run my first servlet in the browser it give me the result of second servlet
my servlet files is located in C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\test\WEB-INF\classes
in the folder classes i have formdata.class TestServlet.class formdata.java TestServlet.java param.html
in the folder WEB-INF i have web.xml which contain


how to run html file with localhost:8080/test/pram or localhost:8080/test and how to write url without the port
and can someone give me instruction how to run jsp in tomcat and how configure web.xml in this case
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3859

Welcome to the CodeRanch!,

how to run html file with localhost:8080/test/pram or localhost:8080/test and how to write url without the port

You can simply access HTML files with their name in the URL. Or you can use <welcome-file-list> in web.xml to define them as a default to a partial URL. For the port if not the default port you have to specify it.

...in the folder classes i have formdata.class TestServlet.class formdata.java TestServlet.java param.html
in the folder WEB-INF i have web.xml which contain

Use proper packages for your servlets, then the problem may solved. And use a separate development directory instead having them inside the server. Only the deployable stuff should go inside the server.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
oussama jlassi
Greenhorn

Joined: Dec 23, 2011
Posts: 25
i use the default package for servlets why different package for them
i can run param.html but i want it in the url that i demanded and explain me more about using tag <welcome-file-list>
even with the class files are only in directory class the problem continued
and for the port i want to write localhost without to specify the port like "http://localhost/"
i deleted the folder test in work\Catalina\localhost to clear the cache but nothing is changing
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61760
    
  67

o jl wrote:i use the default package for servlets why different package for them

The default package is no longer automatically searched as of JDK 1.4. Put all classes in a package, or risk them not working.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
oussama jlassi
Greenhorn

Joined: Dec 23, 2011
Posts: 25
i have added package testservlet to java files after compulation i obtain folder testservlet with class files into it
i changed web.xml and name of class and file formdata to form and the result after starting tomcat is like before

Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3859

Can you show us the hierarchy of the app inside the Tomcat? And what URL you access now? What do you get with http://localhost:8080 ?
Kuldip Shetty
Ranch Hand

Joined: Jan 07, 2010
Posts: 42

Below is the updated web.xml. Each servlet and servlet mapping tag is defined for a particular servlet. As you had added multiple servlets under servlet and servlet mapping tag, this resulted in the different servlet response which you are facing.

oussama jlassi
Greenhorn

Joined: Dec 23, 2011
Posts: 25
thanks Kuldip Shetty with your web.xml the problem is gone \('v')/
can someone answer my last questions
how to run html file with localhost:8080/test/pram or localhost:8080/test and how to write url without to specify each time the port like in apache http "http://localhost"
and can someone give me instruction how to run jsp in tomcat and how configure web.xml in this case
Kuldip Shetty
Ranch Hand

Joined: Jan 07, 2010
Posts: 42

To run the index.html by default for the url localhost:8080/test add the below welcome-file-list tag in web.xml



how to write url without to specify each time the port like in apache http "http://localhost"


Change conf/server.xml file in tomcat server from the default port 8080 to 80 (Default http port). Restart the server after making the configuration changes and access the application using http://localhost
For reference
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19783
    
  20

Just make sure there's no existing web server (IIS, Apache) running on port 80. If there is then you must either stop (and disable) the other web server, or configure the other web server to redirect requests to Tomcat (using AJP / mod_jk).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: tomcat execution problem and other thing