• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get the browser url

 
anwar pasha
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


how to get browser url in java code

ex:

http://serverip:port/contents
 
James Ward
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since it is in browser, wouldn't you want to use javascript?

In JavaScript:
location.href will give you this.


 
Zandis Murāns
Ranch Hand
Posts: 174
Java Java ME Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The javax.servlet.http.HttpServletRequest interface has several methods you can use for the various parts of the URL, including getRequestURI, getQueryString, getScheme, getServerName and getServerPort.
 
Tim Holloway
Bartender
Posts: 18471
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Browsers don't have URLs. Servers do.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!