1

I am currently doing services is java that deploys to different machines, so what I need to to is to get the uri adddress up to the port number in the servlet who called it for example

http://localhost:8080/appname/appaddress

the only thing I need to get is the string from http to 8080 I can do this using javascript or java codes, thanks

null_logic
  • 125
  • 1
  • 1
  • 9

2 Answers2

1

You can use Location object which has these following keys

Location.origin :origin of the specific location

Location.port :Gives port number

brk
  • 46,805
  • 5
  • 49
  • 71
0

In JavaScript:

var baseUrl = window.location.protocol + "//" + window.location.host;

if(window.location.port != "")
  baseUrl += ":" + window.location.port + "/";
Matías Fidemraizer
  • 61,574
  • 17
  • 117
  • 195