1

I've two web applications with one RESTFul service each one. In a service I need to call the second, for example, I Have StatusService and SomeService, depending on state SomeService do some different action. So when I call SomeService its call StatusService to get the current state then do the action.

So, I used reques.getServerPort() in my SomeService to call my StatusService, I have something like this

 URL url = new URL("http://localhost:"+request.getServerPort()+"/app2/status");

It's working when I call the service directly from jboss .

But there are a Apache as a DMZ and only SomeService was externalized, so when I call SomeService via DMZ its try to call http://localhost:80/app2/status rather then http://localhost:8080/app2/status.

Is there another way to get the port?

Thanks in advance.

Lucas Merencia
  • 752
  • 2
  • 5
  • 19

1 Answers1

0

You could try request.getLocalPort

According to the javadocs it returns the port that the request was received on.

DaveH
  • 7,187
  • 5
  • 32
  • 53
  • I tried getLocalPort and getServerPort both of them returned 80 – Lucas Merencia May 24 '13 at 21:08
  • OK : This might help. http://stackoverflow.com/questions/3867197/get-the-server-port-number-from-tomcat-with-out-a-request - but the whole thing looks scarey to me. If I was faced with this, my first approach would be the take the business logic from the StatusService and host it inside the same webapp as the SomeService lives. The just call it as any other java method. Is that a possibility? – DaveH May 24 '13 at 22:18