This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Tomcat and the fly likes avoiding localhost Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "avoiding localhost" Watch "avoiding localhost" New topic
Author

avoiding localhost

jbig zala
Greenhorn

Joined: Sep 20, 2004
Posts: 11
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 ??

Please help me


Learning Never Ends ...................
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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
Sanjaya Sugiarto
Ranch Hand

Joined: Mar 25, 2004
Posts: 229
Try to rename the 'localhost' by editing the hosts file.

If you use Windows than you can find this file under c:\WINNT\system32\drivers\etc. Find 127.0.0.1 and rename 'localhost' to 'myhost' or whatever you want to call it.


<a href="http://www.wi.hs-furtwangen.de" target="_blank" rel="nofollow">Business Information Technology - Hochschule Furtwangen University, Germany</a>
jbig zala
Greenhorn

Joined: Sep 20, 2004
Posts: 11
Thanx for vast information :
Special thanx to Sanjaya Sugiarto
Ramaswamy Srinivasan
Ranch Hand

Joined: Aug 31, 2004
Posts: 295
Hi ppl,

Found the information very useful. thanks a lot.

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.

Cheers,
Swamy
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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
Ramaswamy Srinivasan
Ranch Hand

Joined: Aug 31, 2004
Posts: 295
Hi Bill,

That was really helpful. Thanks a lot for your valuable help.





Cheers,
Swamy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: avoiding localhost