Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

tomcat execution problem and other thing

 
oussama jlassi
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
oussama jlassi
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
oussama jlassi
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 43
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 43
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20529
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic