Solved

Alternative to getServerName() through Servlets

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
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.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
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 …

743 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

11 Experts available now in Live!

Get 1:1 Help Now