view software/mpdl-services/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/util/ServletUtil.java @ 23:e845310098ba

diverse Korrekturen
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Tue, 27 Nov 2012 12:35:19 +0100
parents software/mpdl-services/mpiwg-mpdl-lt-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/util/ServletUtil.java@4a3641ae14d2
children
line wrap: on
line source

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();
  }
  
}