• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

Alternative to getServerName() through Servlets

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
rajneetbhatia
Asked:
rajneetbhatia
  • 2
  • 2
2 Solutions
 
girionisCommented:
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
 
rajneetbhatiaAuthor Commented:
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
 
objectsCommented:
> Actually i want to get the complete path

you can use:

String uri = request.getRequestURI();
0
 
rajneetbhatiaAuthor Commented:
I don't want to use request here.. I want an alternative to this.
0
 
objectsCommented:
There is no alternative, the server name is part of the request.
How could you get it from anything other than the request.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now