How can I get the complete URL address (like "www.jguru.com" (with or without "http://")) from a HttpServletRequest?

JIA Java Italian Association

Have you considered checking the documentation for HttpServletRequest?
It's unbelievable how much interesting stuff you can find. Something like this:

public java.lang.StringBuffer getRequestUrl()

Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters [...].

If you want to extract only the domain name (www.jguru.com) from the url, use getServerName().
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact