• 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

avoiding localhost

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
jbig zala
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx for vast information :
Special thanx to Sanjaya Sugiarto
 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill,

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





Cheers,
Swamy
 
reply
    Bookmark Topic Watch Topic
  • New Topic