Solved

Alternative to getServerName() through Servlets

Posted on 2004-09-22
7
205 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now