public void init() { sbup = new StaticBaseURLProvider(); String baseurl = ServletUtil.getBaseURL2(request); String resourcebaseurl = ServletUtil.getContextBaseURL2(request); sbup.setBaseURL(baseurl); sbup.setResourceBaseURL(resourcebaseurl); }
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { WebApplicationContext wac = (WebApplicationContext) applicationContext; contextURL = ServletUtil.computeContextName(wac.getServletContext()); }
public StaticBaseURLProvider computeBaseURLProvider(HttpServletRequest request) { ServletContext servletcontext = wac.getServletContext(); // yes, these two fields are not request-scope, but not worth creating // a whole new class and bean file for them. resourceurlbase = servletcontext.getInitParameter("resourceurlbase"); if (resourceurlbase == null) { resourceurlbase = ServletUtil.computeContextName(servletcontext); } // compute the baseURLprovider. StaticBaseURLProvider sbup = new StaticBaseURLProvider(); String baseurl = fixSakaiURL(request, ServletUtil.getBaseURL2(request)); sbup.setResourceBaseURL(computeResourceURLBase(baseurl)); // baseurl += SakaiEarlyRequestParser.FACES_PATH + "/"; sbup.setBaseURL(baseurl); return sbup; }
/***************************************************************************** * Computes the "Context Base URL" of this servlet, which will include the * extra stub of the path that refers to the mapping for the specific servlet. */ public static String getContextBaseURL2(HttpServletRequest hsr) { String baseurl = getBaseURL2(hsr); String servletpath = hsr.getServletPath(); if (servletpath == null || servletpath == "") { return baseurl; } int embedpoint = baseurl.lastIndexOf(servletpath); if (embedpoint == -1) { throw new UniversalRuntimeException("Cannot locate servlet path of " + servletpath + " within base url of of " + baseurl); } String togo = baseurl.substring(0, embedpoint); if (togo.charAt(togo.length() - 1) != '/') { togo += '/'; } return togo; } //
public StaticBaseURLProvider computeBaseURLProvider(HttpServletRequest request) { ServletContext servletcontext = wac.getServletContext(); // yes, these two fields are not request-scope, but not worth creating // a whole new class and bean file for them. resourceurlbase = servletcontext.getInitParameter("resourceurlbase"); if (resourceurlbase == null) { resourceurlbase = ServletUtil.computeContextName(servletcontext); } // compute the baseURLprovider. StaticBaseURLProvider sbup = new StaticBaseURLProvider(); String baseurl = fixSakaiURL(request, ServletUtil.getBaseURL2(request)); sbup.setResourceBaseURL(computeResourceURLBase(baseurl)); // baseurl += SakaiEarlyRequestParser.FACES_PATH + "/"; sbup.setBaseURL(baseurl); return sbup; }
String baseURL2 = ServletUtil.getBaseURL2(req); Logger.log.info("baseURL2: " + baseURL2); String requestURI = req.getRequestURL().toString();
public void contextInitialized(ServletContextEvent sce) { ServletContext context = sce.getServletContext(); try { WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(context); if (wac == null) { Logger.log.error("Error locating application context"); return; } locator = wac.getBean(SakaiServletContextLocatorLocator.SAKAI_SCL); if (locator == null) { Logger.log.warn(error); return; } } catch (Exception e) { Logger.log.error(error, e); } String name = context.getInitParameter("sakai-context-name"); if (name == null) { name = ServletUtil.computeContextName(context); } contextName = name; try { Method method = locator.getClass().getMethod("registerContext", new Class[] { String.class, ServletContext.class }); method.invoke(locator, new Object[] { name, context }); } catch (Exception e) { Logger.log.error("Error registering context with name " + name, e); } }
name = ServletUtil.computeContextName(context);