Servlet IP Address and Port

Hi,

I have a servlet running on a host at a specific port number. In the servlet, I have to generate an xml file, where I need to put the URL of the server for DOCTYPE declaration(DTD). So I would like to get the server ip address and port number. How do I get it inside the servlet?

Thanks,
Prasanna
LVL 2
Prasanna_HebbarAsked:
Who is Participating?
 
rkenworthyConnect With a Mentor Commented:
In the ServletRequest object, check out the methods getServerName() and getServerPort().

ServletRequest is the super class of HttpServletRequest which is passed into the get or post methods.

Hope that helps.
Rob
0
 
Prasanna_HebbarAuthor Commented:
Thanks Rob.
0
All Courses

From novice to tech pro — start learning today.