Solved

Alternative to getServerName() through Servlets

Posted on 2004-09-22
7
214 Views
Last Modified: 2013-11-24
Hi,

I am using request.getServerName(), to get the server name through servlets. (where request is the request object). Please let me know how can I get the servername instead of using this request object.

Waiting for reply.

Regards,
R S
0
Comment
Question by:rajneetbhatia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
7 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 25 total points
ID: 12122079
The request object encapsulates the http request into a nice wrapper. Have a look at the source code and see how they do it.
0
 

Author Comment

by:rajneetbhatia
ID: 12122379
Actually i want to get the complete path.
Say I am calling my page as :
http://server1111:8080/ABC/index.html

Presently I am using getServerName method of request object to get
server name as "server".
port as "8080"
Path as "ABC"

Now instead of using this request object I want to get the servername using some other way, how can I do that.

Waiting for reply.
0
 
LVL 92

Expert Comment

by:objects
ID: 12128826
> Actually i want to get the complete path

you can use:

String uri = request.getRequestURI();
0
 

Author Comment

by:rajneetbhatia
ID: 12130407
I don't want to use request here.. I want an alternative to this.
0
 
LVL 92

Assisted Solution

by:objects
objects earned 25 total points
ID: 12130430
There is no alternative, the server name is part of the request.
How could you get it from anything other than the request.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do I remove an object from a 3 60
Which non-HTML GUI front end to use with Java? 3 65
ejb entity bean example 2 56
java imports not found 4 70
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question