m using tomcat4 on win2k os to learn servlet, jsp. To test servlets i evertime write as http://localhost:8080/servlet/servletname i don't wont to write localhost. instead i want to create my own host named 'myhost' into tomcat and place my servelts into it. so i can test my servlet using url like http://myhost/servlet/servletname . can is it possible ? what neccessary steps i need to have ? if it possible . where i have to place my servlets and web.xml files ??
Do you mean that you want people out on the Internet to address your website or just that you don't want to use the word "localhost"? Tomcat does not carry out the process that matches your URL with an address, it just waits on a specific port. You can change the port it waits on to port 80 in the server.xml configuration file, then you could use: http://localhost/someservlet because http will assume port 80. Your use of "/servlet/servletname" in the URL indicates that you need to read the invoker servlet FAQ. Bill
By the way, as an extension to this thread, my question is,I have a folder in webapps say systrack. Inside systrack, i have track1, and track2 folders.
Now Inside track2, i have some files say 10 files.
When i call track2, all the files get listed. What do i do to prevent this?
Any help would be highly appreciated.
Author and all-around good cowpoke
Joined: Mar 22, 2000
To prevent directory listings - in the ../conf/web.xml file look for the definition of the "default" servlet:
This is the servlet that handles requests if no other servlet match can be found. The "listings" value is true as Tomcat is installed - I suppose they did it that way so you can get some feedback during development. Just set it to "false" Bill
Joined: Aug 31, 2004
That was really helpful. Thanks a lot for your valuable help.