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
  • 48,835
  • 10
  • 56
  • 78
0

In JavaScript:

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

if(window.location.port != "")
  baseUrl += ":" + window.location.port + "/";
Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206