diff software/mpdl-services/mpiwg-mpdl-lt-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/util/ServletUtil.java @ 19:4a3641ae14d2

Erstellung
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Wed, 09 Nov 2011 15:32:05 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services/mpiwg-mpdl-lt-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/util/ServletUtil.java	Wed Nov 09 15:32:05 2011 +0100
@@ -0,0 +1,27 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.util;
+
+import javax.servlet.http.HttpServletRequest;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+
+public class ServletUtil {
+  private static ServletUtil instance;
+
+  public static ServletUtil getInstance() throws ApplicationException {
+    if (instance == null) {
+      instance = new ServletUtil();
+    }
+    return instance;
+  }
+
+  public ServletUtil() {
+  }
+
+  public String getBaseUrl( HttpServletRequest request ) {
+    if (request.getServerPort() == 80 || request.getServerPort() == 443)
+      return request.getScheme() + "://" + request.getServerName() + request.getContextPath();
+    else
+      return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
+  }
+  
+}