Mercurial > hg > mpdl-group
diff software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/util/ServletUtil.java @ 25:e9fe3186670c default tip
letzter Stand eingecheckt
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 21 May 2013 10:19:32 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/util/ServletUtil.java Tue May 21 10:19:32 2013 +0200 @@ -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(); + } + +}