• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

tomcat execution problem and other thing

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Ranch Hand
Posts: 45
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 45
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
reply
    Bookmark Topic Watch Topic
  • New Topic