diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java
index 10b2ec77206..ae22656cd97 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java
@@ -166,6 +166,16 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf
if("/".equals(swagger.getBasePath())) {
swagger.setBasePath("");
}
+
+ String host = swagger.getHost();
+ String port = "8080";
+ if(host != null) {
+ String[] parts = host.split(":");
+ if(parts.length > 0) {
+ port = parts[1];
+ }
+ }
+ this.additionalProperties.put("serverPort", port);
if(swagger != null && swagger.getPaths() != null) {
for(String pathname : swagger.getPaths().keySet()) {
Path path = swagger.getPath(pathname);
diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/README.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/README.mustache
index f240464851d..7bad8dbee0a 100644
--- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/README.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/README.mustache
@@ -16,7 +16,7 @@ mvn clean package jetty:run
You can then view the swagger listing here:
```
-http://localhost:8080{{contextPath}}/swagger.json
+http://localhost:{{serverPort}}{{contextPath}}/swagger.json
```
Note that if you have configured the `host` to be something other than localhost, the calls through
diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/pom.mustache
index b8426a0a693..0d1b06de43a 100644
--- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/pom.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/pom.mustache
@@ -37,7 +37,7 @@
8079
stopit
- 8080
+ {{serverPort}}
60000