?
Solved

Alternative to getServerName() through Servlets

Posted on 2004-09-22
7
Medium Priority
?
222 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 100 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 100 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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 …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

765 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