This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes method returns server host Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "method returns server host" Watch "method returns server host" New topic
Author

method returns server host

sridhar ponnusamy
Greenhorn

Joined: Sep 07, 2008
Posts: 19
which HttpServletRequest method returns host
for eg: my servletpath is http://www.myapp.com/myservlet/myaction.do

which method returns this "www.myapp.com"

thanks in advance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41125
    
  45
Remember that HttpServletRequest extends ServletRequest, and thereby inherits quite a few useful methods from it.


Ping & DNS - my free Android networking tools app
sridhar ponnusamy
Greenhorn

Joined: Sep 07, 2008
Posts: 19
yes thanks...but which method returns that "www.myapp.com"
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41125
    
  45
Did you really not notice any method that looks like it might do that?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Step 1) Write a servlet that calls the various methods
Step 2) Write the results to the console or response
Step 3) See which one returns the data you seek
Step 4) Profit!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sridhar ponnusamy
Greenhorn

Joined: Sep 07, 2008
Posts: 19
yes i noticed, so many methods are there...but am running server locally,hence am getting localhost,8080....etc thats why am asking which method will meet my requirement....
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


yes i noticed, so many methods are there...but am running server locally,hence am getting localhost,8080....etc thats why am asking which method will meet my requirement....

So you have the hostname? I'm not sure what else you want? Are you trying to get the public DNS name for a specific IP address?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
Don't get me started about those stupid light bulbs.
 
subject: method returns server host
 
Similar Threads
Modify struts url
Starting Multiple servers within one domain on WebLogic6.0
Problem with favicon.ico
request.getQueryString() doesn't work ?
Invoke struts action using relative path through URL class