当前位置: 首页>>代码示例>>Java>>正文


Java HttpServletRequest.getScheme方法代码示例

本文整理汇总了Java中javax.servlet.http.HttpServletRequest.getScheme方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServletRequest.getScheme方法的具体用法?Java HttpServletRequest.getScheme怎么用?Java HttpServletRequest.getScheme使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.http.HttpServletRequest的用法示例。


在下文中一共展示了HttpServletRequest.getScheme方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRequestURL

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
public static String getRequestURL(HttpServletRequest request, boolean includeQueryString) {
	StringBuffer url = new StringBuffer();
       String scheme = request.getScheme();
       int port = request.getServerPort();
       String urlPath = request.getRequestURI();

       url.append (scheme);                // http, https
       url.append ("://");
       url.append (request.getServerName());
       if ((scheme.equals ("http") && port != 80)
               || (scheme.equals ("https") && port != 443)) {
           url.append (':');
           url.append (request.getServerPort());
       }
       url.append(urlPath);
       if(includeQueryString && !StringUtils.isEmpty(request.getQueryString())){
       	url.append("?" + request.getQueryString());
	}
       return url.toString();
}
 
开发者ID:penggle,项目名称:xproject,代码行数:21,代码来源:HttpUtils.java

示例2: PdfExamReportQueueItem

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
public PdfExamReportQueueItem(Session session, UserContext owner, ExamPdfReportForm form, HttpServletRequest request, ExamSolverProxy examSolver) {
	super(session, owner);
	iForm = form;
	iUrl = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath();
	iExamSolver = examSolver;
	iName = ExamTypeDAO.getInstance().get(iForm.getExamType()).getLabel() + " ";
       for (int i=0;i<iForm.getReports().length;i++) {
       	if (i > 0) iName += ", ";
       	iName += iForm.getReports()[i];
       }
       if (!iForm.getAll()) {
       	iName += " (";
           for (int i=0;i<iForm.getSubjects().length;i++) {
               SubjectArea subject = new SubjectAreaDAO().get(Long.valueOf(iForm.getSubjects()[i]));
               if (i > 0) iName += ", ";
               iName += subject.getSubjectAreaAbbreviation();
           }
           iName += ")";
       }
       iSubjectIndependent = (owner == null || owner.getCurrentAuthority() == null ? false : owner.getCurrentAuthority().hasRight(Right.DepartmentIndependent));
       iForm.setSubjectAreas(SubjectArea.getUserSubjectAreas(owner, false));
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:23,代码来源:PdfExamReportQueueItem.java

示例3: getDefaultBackUrl

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
private String getDefaultBackUrl(HttpServletRequest request) {
	String scheme = request.getScheme();
	String domain = request.getServerName();
	int port = request.getServerPort();
	String contextPath = request.getContextPath();
	StringBuilder backUrl = new StringBuilder(scheme);
	backUrl.append("://");
	backUrl.append(domain);
	if ("http".equalsIgnoreCase(scheme) && port != 80) {
		backUrl.append(":").append(String.valueOf(port));
	} else if ("https".equalsIgnoreCase(scheme) && port != 443) {
		backUrl.append(":").append(String.valueOf(port));
	}
	backUrl.append(contextPath);
	backUrl.append(getSuccessUrl());
	return backUrl.toString();
}
 
开发者ID:jiangzongyao,项目名称:kettle_support_kettle8.0,代码行数:18,代码来源:Authentication2Filter.java

示例4: doFilterInternal

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
    String requestURI = request.getRequestURI();
    requestURI = requestURI.replaceAll("/+", "/").replaceAll("/+", "/");
    LOG.info("LoginFilter receive request uri : " + requestURI);

    if (requestURI.equals("/")||requestURI.equals("/web/login")||requestURI.equals("/web/doLogin")||requestURI.startsWith("/resources")|| requestURI.startsWith("/terminal/")) {
        filterChain.doFilter(request, response);
        return;
    }
    String path = request.getContextPath();
    this.basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";

    HttpSession session = request.getSession();

    BumblebeeUser user=(BumblebeeUser) session.getAttribute("curUser");
    if(null==user){
        java.io.PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<script>");
        out.println("window.open ('"+basePath+"','_top')");
        out.println("</script>");
        out.println("</html>");
    }else{
        filterChain.doFilter(request, response);
        return;
    }


}
 
开发者ID:gy-games,项目名称:bumblebee,代码行数:31,代码来源:LoginFilter.java

示例5: getMostPreferredConnectionURL

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
 * Generates an URL on which client / BOSH connections are expected.
 *
 * This method will verify if the websocket plugin is available. If it is, the websocket endpoint is returned. When
 * websocket is not available, the http-bind endpoint is returned.
 *
 * The request that is made to this servlet is used to determine if the client prefers secure/encrypted connections
 * (https, wss) over plain ones (http, ws), and to determine what the server address and port is.
 *
 * @param request the request to this servlet.
 * @return An URI (never null).
 * @throws URISyntaxException When an URI could not be constructed.
 */
public static URI getMostPreferredConnectionURL( HttpServletRequest request ) throws URISyntaxException
{
    Log.debug( "[{}] Generating BOSH URL based on {}", request.getRemoteAddr(), request.getRequestURL() );
    if ( XMPPServer.getInstance().getPluginManager().getPlugin( "websocket" ) != null )
    {
        Log.debug( "[{}] Websocket plugin is available. Returning a websocket address.", request.getRemoteAddr() );
        final String websocketScheme;
        if ( request.getScheme().endsWith( "s" ) )
        {
            websocketScheme = "wss";
        }
        else
        {
            websocketScheme = "ws";
        }

        return new URI( websocketScheme, null, request.getServerName(), request.getServerPort(), "/ws", null, null);
    }
    else
    {
        Log.debug( "[{}] No Websocket plugin available. Returning an HTTP-BIND address.", request.getRemoteAddr() );
        return new URI( request.getScheme(), null, request.getServerName(), request.getServerPort(), "/http-bind/", null, null);
    }
}
 
开发者ID:igniterealtime,项目名称:ofmeet-openfire-plugin,代码行数:38,代码来源:ConfigServlet.java

示例6: Saved2Request

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
public Saved2Request(HttpServletRequest request, String backUrl) {
	super(request);
	this.scheme = request.getScheme();
	this.domain = request.getServerName();
	this.port = request.getServerPort();
	this.backUrl = backUrl;
	this.contextPath = request.getContextPath();
}
 
开发者ID:jiangzongyao,项目名称:kettle_support_kettle8.0,代码行数:9,代码来源:Saved2Request.java

示例7: testIncomingRequestIsSecuredButProtocolHeaderSaysItIsNotWithCustomValues

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@Test
public void testIncomingRequestIsSecuredButProtocolHeaderSaysItIsNotWithCustomValues() throws Exception {
    // PREPARE
    FilterDef filterDef = new FilterDef();
    filterDef.addInitParameter("protocolHeader", "x-forwarded-proto");
    filterDef.addInitParameter("remoteIpHeader", "x-my-forwarded-for");
    filterDef.addInitParameter("httpServerPort", "8080");

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteAddr("192.168.0.10");
    request.setSecure(true);
    request.setScheme("https");
    request.setHeader("x-my-forwarded-for", "140.211.11.130");
    request.setHeader("x-forwarded-proto", "http");

    // TEST
    HttpServletRequest actualRequest = testRemoteIpFilter(filterDef, request).getRequest();

    // VERIFY
    boolean actualSecure = actualRequest.isSecure();
    assertFalse("request must be unsecured as header x-forwarded-proto said it is http", actualSecure);

    String actualScheme = actualRequest.getScheme();
    assertEquals("scheme must be http as header x-forwarded-proto said it is http", "http", actualScheme);

    int actualServerPort = actualRequest.getServerPort();
    assertEquals("wrong http server port", 8080, actualServerPort);

    String actualRemoteAddr = actualRequest.getRemoteAddr();
    assertEquals("remoteAddr", "140.211.11.130", actualRemoteAddr);

    String actualRemoteHost = actualRequest.getRemoteHost();
    assertEquals("remoteHost", "140.211.11.130", actualRemoteHost);
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:35,代码来源:TestRemoteIpFilter.java

示例8: getApplicationRootUrl

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
public static String getApplicationRootUrl() {
	try {
		HttpServletRequest request = ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest());
		URL reconstructedUrl = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), "");
		return reconstructedUrl.toString();
	} catch (Exception e) {
		return getHttpBaseUrl();
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:10,代码来源:WebUtil.java

示例9: getFullURL

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
 * 获取Http请求的完整路径,包括参数
 *
 * @param request
 * @return
 */
public static String getFullURL(HttpServletRequest request) {
	String url = "";
	url = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getServletPath();
	if (request.getQueryString() != null) {
		url += "?" + request.getQueryString();
	}
	return url;
}
 
开发者ID:funtl,项目名称:framework,代码行数:15,代码来源:RequestUtils.java

示例10: getFullURLWithOutPort

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
 * 获取Http请求的完整路径,包括参数,不包括端口号
 *
 * @param request
 * @return
 */
public static String getFullURLWithOutPort(HttpServletRequest request) {
	String url = "";
	url = request.getScheme() + "://" + request.getServerName() + request.getServletPath();
	if (request.getQueryString() != null) {
		url += "?" + request.getQueryString();
	}
	return url;
}
 
开发者ID:funtl,项目名称:framework,代码行数:15,代码来源:RequestUtils.java

示例11: DataExchangeQueueItem

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
public DataExchangeQueueItem(Session session, UserContext owner, DataImportForm form, HttpServletRequest request, boolean isImport) {
	super(session, owner);
	iForm = (DataImportForm)form.clone();
	iUrl = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath();
	iImport = isImport;
	iSessionName = session.getAcademicTerm() + session.getAcademicYear() + session.getAcademicInitiative();
	iProgress = Progress.getInstance(this);
	iProgress.addProgressListener(new ProgressListener() {
		@Override
		public void statusChanged(String status) {
			log(status);
		}
		
		@Override
		public void progressSaved() {}
		
		@Override
		public void progressRestored() {}
		
		@Override
		public void progressMessagePrinted(Message message) {
			log(message.toHtmlString());
		}
		
		@Override
		public void progressChanged(long currentProgress, long maxProgress) {}
		
		@Override
		public void phaseChanged(String phase) {}
	});
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:32,代码来源:DataImportAction.java

示例12: execute

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@Override
public String execute() throws Exception {
	HttpServletRequest request=Struts2Utils.getRequest();
	String tabId=request.getParameter("tabId");

	String baseUrl = "";
	baseUrl = request.getScheme() +"://" + request.getServerName()  
					+ (request.getServerPort() == 80 ? "" : ":" +request.getServerPort())
                       + request.getContextPath();

	request.setAttribute("baseUrl", baseUrl);

	User user=accountManager.getCurUser();
   	if(user!=null){
   		SurveyDirectory surveyDirectory=surveyDirectoryManager.getSurveyByUser(surveyId, user.getId());
   		if(surveyDirectory!=null){
   			request.setAttribute("survey", surveyDirectory);
   			if(IFRAME.equals(tabId)){
   				return IFRAME;
   			}else if(SITECOMP.equals(tabId)){
   				return SITECOMP;
   			}else if(WEIXIN.equals(tabId)){
   				return WEIXIN;
   			}else if(SHARE.equals(tabId)){
   				return SHARE;
   			}
   			return COLLECT1;
   		}
   	}
	return null;
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:32,代码来源:MyCollectAction.java

示例13: getServerScheme

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
protected String getServerScheme(HttpServletRequest request)
{
	String scheme = sysAdminParams.getAlfrescoProtocol();
       if (scheme == null)
       {
           scheme = request.getScheme();
       }
       scheme = request.getScheme();
       return scheme;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:11,代码来源:SysAdminParamsBaseUrlGenerator.java

示例14: sendEmail

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
 * 发送邮箱验证码
 * @param email 邮箱账号
 * @param request
 * @return
 */
@ResponseBody
@RequestMapping(value = "/sendEmail",method = RequestMethod.POST)
public ResponseEntity sendEmail(String email, HttpServletRequest request){
    if(email==null||!ValidateUtils.isEmail(email)){
        return new ResponseEntity(400,"error","邮箱账号错误!");
    }
    //发送注册邮件
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+ request.getContextPath()+"/";
    Map<String,Object> modelMap=new HashMap<String,Object>();
    modelMap.put("USERNAME","baby慕慕");
    modelMap.put("LOGOIMG",basePath+"resources/img/logo.png");
    int verifyCode = RandomUtils.nextInt(100000, 999999);
    request.getSession().setAttribute("VERIFYCODE",String.valueOf(verifyCode));
    modelMap.put("VERIFYCODE",verifyCode);
    modelMap.put("IFORGOTURL",basePath+"system/iforget");
    modelMap.put("LOGINURL",basePath+"system/login");
    modelMap.put("OFFICIALURL",basePath);
    String content= VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "tpl/verifyCodeEmail.html","UTF-8",modelMap);
    try {
        boolean sendSuccess=emailService.send(email,null,"baby慕慕开放平台-验证码找回密码",content);
        if(sendSuccess){
            return new ResponseEntity(200,"success","验证码发送成功");
        }
    } catch (EmailException e) {
        e.printStackTrace();
    }
    return new ResponseEntity(400,"error","邮箱发送失败!");
}
 
开发者ID:babymm,项目名称:mumu,代码行数:35,代码来源:SysIforgetController.java

示例15: testIncomingRequestIsSecuredButProtocolHeaderSaysItIsNotWithDefaultValues

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@Test
public void testIncomingRequestIsSecuredButProtocolHeaderSaysItIsNotWithDefaultValues() throws Exception {
    // PREPARE
    FilterDef filterDef = new FilterDef();
    filterDef.addInitParameter("protocolHeader", "x-forwarded-proto");

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteAddr("192.168.0.10");
    request.setSecure(true);
    request.setScheme("https");
    request.setHeader("x-forwarded-for", "140.211.11.130");
    request.setHeader("x-forwarded-proto", "http");

    // TEST
    HttpServletRequest actualRequest = testRemoteIpFilter(filterDef, request).getRequest();

    // VERIFY
    boolean actualSecure = actualRequest.isSecure();
    assertFalse("request must be unsecured as header x-forwarded-proto said it is http", actualSecure);

    String actualScheme = actualRequest.getScheme();
    assertEquals("scheme must be http as header x-forwarded-proto said it is http", "http", actualScheme);

    String actualRemoteAddr = actualRequest.getRemoteAddr();
    assertEquals("remoteAddr", "140.211.11.130", actualRemoteAddr);

    String actualRemoteHost = actualRequest.getRemoteHost();
    assertEquals("remoteHost", "140.211.11.130", actualRemoteHost);

}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:31,代码来源:TestRemoteIpFilter.java


注:本文中的javax.servlet.http.HttpServletRequest.getScheme方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。