Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Looking up webserver's hostname from applet

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've designed an applet that connects to a custom server running on the same machine as the webserver. There aren't any issues making the actual connection. The question I have, however, is how to properly find the webserver hostname without hard-coding it into the applet. As I see it (and there are other ways please add) there are two ways to set the desired webserver hostname:

1) As a parameter to the applet coded into the applet on the HTML file. For example: <param name=host value='hostname'>
2) The applet could look up the server's hostname

Option 1 works fine but is there an easy way to look up the webserver's hostname from within an Applet as in option 2?

-Dave
 
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Applet.getCodeBase()
or
Applet.getDocumentBase()

should work for you
 
Let me tell you a story about a man named Jed. He made this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic