本文整理汇总了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();
}
示例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));
}
示例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();
}
示例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;
}
}
示例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);
}
}
示例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();
}
示例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);
}
示例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();
}
}
示例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;
}
示例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;
}
示例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) {}
});
}
示例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;
}
示例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;
}
示例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","邮箱发送失败!");
}
示例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);
}