Win a copy of Event Streams in Action this week in the Java in General 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

HttpServletRequest questions

 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guy's
I have a web app (go figure servlet - web app) standard url form https://foo.com/appName. It is on a cluster of IBM websphere servers being served by several nodes: hosta.foo.com, hostb.foo.com, hostc.foo.com


My question HttpServletRequest.getServerName() would it be foo.com or hosta.foo.com? (I think just foo.com) with HttpServletRequest.getLocalName() returning hosta.foo.com?

can someone one definitively confirm that behavior?? On my local dev env. It all shows up as localhost.
 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you do a testing servlet and find out yourself?
 
peter cooke
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that when I do that in my local dev env the httpServletRequest. Has"localhost".

I'm not allowed to set a remote debuger or install VM.

I guess I could find an old laptop to simulate requests for foo.com/app versus qa.foo.com/app versus ua.foo.com
 
Marshal
Posts: 67273
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can configure alternate domain names to use in place of localhost for testing in your /etc/hosts file -- assuming you're on a real OS. If you are using Windows, I'm sure that there are other ways to do the same thing.

 
Rancher
Posts: 43011
76
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Windows uses the same kind of host file as Unix-ish OSes. It's in %systemroot%\system32\drivers\etc\
 
Bear Bibeault
Marshal
Posts: 67273
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Ulf.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!