List of usage examples for javax.servlet.http HttpServletRequest getServerName
public String getServerName();
From source file:com.mycompany.frogsssa.testDD.java
@Override public void data(String source, byte[] data) { String msg = new String(data); System.out.println("DATA src: " + source + " d: " + msg); if (msg.substring(0, 10).equals("REGISTERED")) { if (!msg.contains(":")) { System.out.println("Wrong response format from the configuration architecture\n" + "Expected REGISTERED:<ID app> instead of " + msg); }/*from w w w .j av a2 s.c o m*/ String id = msg.split(":")[1]; //URI ad = uriInfo.getBaseUri(); MessageContext msgCtxt = ConnectionModule.wsCtxt.getMessageContext(); HttpServletRequest request = (HttpServletRequest) msgCtxt.get(MessageContext.SERVLET_REQUEST); String hostName = request.getServerName(); int port = request.getServerPort(); String contextPath = request.getContextPath(); String uri = "http://" + hostName + ":" + port + contextPath; this.publish("public." + id + "/restServer", uri); } ConnectionModule.someConfiguration(this.name, new String(data)); }
From source file:fr.aliasource.webmail.server.OBMSSOProvider.java
@Override public Credentials obtainCredentials(Map<String, String> settings, HttpServletRequest req) { String ticket = req.getParameter("ticket"); if (ticket == null) { logger.warn("no ticket in url"); return null; }/*from w w w. j a va 2s.c o m*/ try { String logoutUrl = req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort() + req.getContextPath() + "/session;jsessionid=" + req.getSession().getId(); URL url = new URL(settings.get(SSO_SERVER_URL) + "?action=validate&ticket=" + ticket + "&logout=" + URLEncoder.encode(logoutUrl, "UTF-8")); InputStream in = url.openStream(); String content = IOUtils.toString(in); in.close(); if (logger.isDebugEnabled()) { logger.debug("SSO server returned:\n" + content); } Credentials creds = null; if (!content.equals("invalidOBMTicket")) { String[] ssoServerReturn = content.split("&password="); String login = ssoServerReturn[0].substring("login=".length()); String pass = ssoServerReturn[1]; creds = new Credentials(URLDecoder.decode(login, "UTF-8"), URLDecoder.decode(pass, "UTF-8")); } return creds; } catch (Exception e) { logger.error("Ticket validation error: " + e.getMessage(), e); return null; } }
From source file:com.camel.framework.tag.CssLinkTag.java
/** * ????Coogle Minify?,??/* ww w . j a v a 2 s . co m*/ */ private void parse() { StringBuffer sb = new StringBuffer(); // jspJspWriter JspWriter out = this.pageContext.getOut(); // environmentConfig.xml?????value String resourcesUrl = null; if (null != ConfigParamMap.getConfigParamMap()) { ConfigParamMap.getValue(IEnvironmentConfigBasic.RESOURCES_URL); } // ?null??URL if (null == resourcesUrl) { HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); resourcesUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); } /** * ?environmentConfig.xml?resources_merger * ?jscss?,Ygoogle minify N? */ String resourcesMerger = null; if (null != ConfigParamMap.getConfigParamMap()) { ConfigParamMap.getValue(IEnvironmentConfigBasic.RESOURCES_MERGER); } if (ITagBasic.USER_MINIFY_CODE.equals(resourcesMerger)) { // ?? Minify?link?? parseToMinifyStyle(sb, resourcesUrl, out); } else { // path????? // ??? Minify?script?? parseToConventionalStyle(sb, resourcesUrl, out); } }
From source file:com.comcast.cdn.traffic_control.traffic_router.core.request.HTTPRequest.java
public void applyRequest(final HttpServletRequest request) { setClientIP(request.getRemoteAddr()); setPath(request.getPathInfo());/*from w w w . ja v a 2s . c om*/ setQueryString(request.getQueryString()); setHostname(request.getServerName()); setRequestedUrl(request.getRequestURL().toString()); setUri(request.getRequestURI()); final String xmm = request.getHeader(X_MM_CLIENT_IP); final String fip = request.getParameter(FAKE_IP); if (xmm != null) { setClientIP(xmm); } else if (fip != null) { setClientIP(fip); } final Map<String, String> headers = new HashMap<String, String>(); final Enumeration<?> headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { final String name = (String) headerNames.nextElement(); final String value = request.getHeader(name); headers.put(name, value); } setHeaders(headers); secure = request.isSecure(); }
From source file:com.camel.framework.tag.ScriptTag.java
/** * ?????Coogle Minify?,??// w w w. j a v a 2 s . c o m */ private void parse() { StringBuffer sb = new StringBuffer(); // jspJspWriter JspWriter out = this.pageContext.getOut(); // environmentConfig.xml?????value String resourcesUrl = null; if (null != ConfigParamMap.getConfigParamMap()) { ConfigParamMap.getValue(IEnvironmentConfigBasic.RESOURCES_URL); } // ?null??URL if (null == resourcesUrl) { HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); resourcesUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); } /** * ?environmentConfig.xml?resources_merger * ?jscss?,Ygoogle minify N? */ String resourcesMerger = null; if (null != ConfigParamMap.getConfigParamMap()) { ConfigParamMap.getValue(IEnvironmentConfigBasic.RESOURCES_MERGER); } if (ITagBasic.USER_MINIFY_CODE.equals(resourcesMerger)) { // ?? Minify?script?? parseToMinifyStyle(sb, resourcesUrl, out); } else { // ??? Minify?script?? parseToConventionalStyle(sb, resourcesUrl, out); } }
From source file:org.magnum.dataup.VideoSvcCtrl.java
/** * Helps the helper method for getting the url of a video by * generating the urlbase for a local server *///from w ww.j av a2 s. com public String getUrlBaseForLocalServer() { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) .getRequest(); String base = "http://" + request.getServerName() + ((request.getServerPort() != 80) ? ":" + request.getServerPort() : ""); return base; }
From source file:com.spstudio.session.filter.SessionAOP.java
@Around(value = "@annotation(com.spstudio.session.UserSession)") public Object aroundManager(ProceedingJoinPoint pj) throws Exception { HttpServletRequest request = SysContent.getRequest(); HttpServletResponse response = SysContent.getResponse(); HttpSession session = SysContent.getSession(); String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; UserSessionType type = this.getSessionType(pj); if (type == null) { throw new Exception("The value of NeedSession is must."); }/* w w w.ja v a 2 s . c o m*/ Object uobj = session.getAttribute("user"); Object mobj = session.getAttribute("manager"); boolean isUser = type == UserSessionType.USER && uobj != null; boolean isManager = type == UserSessionType.MANAGER && mobj != null; boolean isUserOrManager = type == UserSessionType.OR && (mobj != null || uobj != null); try { if (isUser || isManager || isUserOrManager) { return pj.proceed(); } else { // ?session if (request.getHeader("x-requested-with") != null && request.getHeader("x-requested-with").equalsIgnoreCase( //ajax? "XMLHttpRequest")) { response.addHeader("sessionstatus", "timeout"); // EasyUi //response.getWriter().print("{\"rows\":[],\"success\":false,\"total\":0}"); } else {//http? response.sendRedirect(basePath + "error/nosession"); } } } catch (Throwable e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:grails.plugin.springsecurity.web.GrailsRedirectStrategy.java
protected String calculateRedirectUrl(HttpServletRequest request, String url) { if (UrlUtils.isAbsoluteUrl(url)) { return url; }/* w ww . j a v a 2s . c o m*/ url = request.getContextPath() + url; if (!useHeaderCheckChannelSecurity) { return url; } return UrlUtils.buildFullRequestUrl(request.getScheme(), request.getServerName(), portResolver.getServerPort(request), url, null); }
From source file:org.openmrs.module.sync.web.controller.EmailConfigController.java
@RequestMapping("/module/sync/sendTestEmail") public void sendTestEmail(@RequestParam("recipients") String recipients, @RequestParam("subject") String subject, @RequestParam("emailBody") String emailBody, HttpServletRequest request, HttpServletResponse response) throws Exception { MessageSourceService mss = Context.getMessageSourceService(); String results = mss.getMessage("sync.emailConfig.messageSendSuccessful"); try {//from ww w . j a v a2 s .c o m String serverName = request.getServerName(); SyncMailUtil.sendMessage(recipients, serverName + ": " + subject, emailBody); } catch (Exception e) { results = mss.getMessage("sync.emailConfig.messageSendFailed") + ": " + e.getMessage(); } response.setContentType("text/json"); response.getWriter().write(toJson(results)); }