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


Java HttpServletResponse.sendRedirect方法代码示例

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


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

示例1: forwardToLogin

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
private boolean forwardToLogin(HttpServletRequest request,
                               HttpServletResponse response) throws ServletException, IOException {
    String url = "http://" + request.getServerName() + ":"
            + request.getServerPort() + request.getContextPath()
            + "/login.jsp";
    response.sendRedirect(url);
    return false;
}
 
开发者ID:tomoncle,项目名称:JavaStudy,代码行数:9,代码来源:AuthInterceptorAdapter.java

示例2: doFilter

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    HttpServletRequest hsrq = (HttpServletRequest) request;
    HttpServletResponse hsrp = (HttpServletResponse) response;
    String clientType = hsrq.getParameter("clientType");
    if ("WORD".equals(clientType)) {
        chain.doFilter(request, response);
    } else {
        SessionUser person = null;
        String reqPage = hsrq.getServletPath();
        if (!reqPage.trim().equals("/login.do") && !reqPage.trim().equals("/logout.do")
                ) {
            person = (SessionUser) hsrq.getSession().getAttribute(SysConstants.SESSION_USER_KEY);
            if (person == null) {
                hsrp.sendRedirect("login.do");
                return;
            }
        }
        chain.doFilter(request, response);
    }

}
 
开发者ID:JiaXiaohei,项目名称:ssm-web,代码行数:22,代码来源:CheckSessionOutFilter.java

示例3: handle

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
public void handle(HttpServletRequest httpServletRequest,
                   HttpServletResponse httpServletResponse,
                   AccessDeniedException e) throws IOException {

    Authentication auth = SecurityContextHolder.getContext().getAuthentication();

    // Log access attempts
    if (auth != null) {
        logger.info("User '" + auth.getName() + "' attempted to access the protected URL: "
                + httpServletRequest.getRequestURI());
    }

    // Direct user to access denied page
    httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + "/403");
}
 
开发者ID:ericywl,项目名称:InfoSys-1D,代码行数:17,代码来源:ProfChoperAccessDeniedHandler.java

示例4: doGet

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
      HttpSession sessao = request.getSession();  
      ArrayList<Fornecedor> Lista = new ArrayList();
      ServicoFornecedor sf = new ServicoFornecedor();
      String codigoempresa = (String) sessao.getAttribute("Empresa");
      
      try {
        Lista = (ArrayList<Fornecedor>) sf.listarFornecedor("", Integer.parseInt(codigoempresa));
    } catch (Exception e) {
    }
    
      sessao.setAttribute("ListaFornecedoresProd", Lista);
      
      RequestDispatcher dispatcher
 = request.getRequestDispatcher("/cadastroProduto.jsp");
dispatcher.forward(request, response);
response.sendRedirect(request.getContextPath() + "/cadastroProduto.jsp"); 
}
 
开发者ID:Dinossaura,项目名称:LojaDeInstrumentosMusicais,代码行数:21,代码来源:ConsultaFornecedorProdServlet.java

示例5: logout

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * 用户登出系统
 */
@RequestMapping("/logout")
public void logout(HttpServletRequest request, HttpServletResponse response) throws IOException
{
	try
	{
		MyCookie cookie = new MyCookie(request, response);
		String cookieTicket = String.valueOf(cookie.getValue(SessionListener.DS_SSO_TICKET));
		service.saveLogLogout(String.valueOf(cookieTicket), false, false);
		if(!cookieTicket.equals("null") && cookieTicket.length() > 0)
		{
			removeLoginInfo(request, response);// 试着删除
		}
	}
	catch(Exception e)
	{
		log.error(e.getMessage());
	}
	MyRequest req = new MyRequest(request);
	String serviceURL = java.net.URLEncoder.encode(req.getString("service", request.getContextPath() + "/ticket.jsp"), "UTF-8");
	response.sendRedirect(request.getContextPath() + "/login?service=" + String.valueOf(serviceURL));
	return;
}
 
开发者ID:skeychen,项目名称:dswork,代码行数:26,代码来源:AuthController.java

示例6: doGet

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	CreateSurveySessionManager session = new CreateSurveySessionManager(request);
	if (securityService.isLoggedIn()) {
		if (session.hasSurveyModel()) {
			request.getRequestDispatcher("WEB-INF/createsurvey/createsurvey.jsp").forward(request, response);
			session.clearErrorMessages();
		} else {
			response.sendRedirect("lecturer");
			session.clearErrorMessages();
		}
	} else {
		session.setErrorMessage(ErrorMessage.NOT_LOGGED_IN);
		response.sendRedirect("index");
	}
}
 
开发者ID:erikns,项目名称:webpoll,代码行数:19,代码来源:SurveyBuilderServlet.java

示例7: handlePost

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
public void handlePost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	String path = getPath(request);
	
	System.out.println("GUIPOSTPATH "+path);
	if (path.equals("login")) {
		String email = request.getParameter("email");
		String pwd = request.getParameter("pword");
		System.out.println("LoggingIn "+email);
		IResult r = model.authenticate(email, pwd);
		ITicket t = (ITicket)r.getResultObject();
		if (t != null) {
			String rtoken = newUUID();
			
			credentialCache.putTicket(rtoken, t);
			response.sendRedirect("/gui/menu/"+rtoken);
		}
	}

			
}
 
开发者ID:topicquests,项目名称:backside-servlet-ks,代码行数:21,代码来源:GUIHandler.java

示例8: doLogin

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * do login
 * @param user userInfo
 * @param request requestInfo
 * @param response responseInfo
 * @param map data
 * @return login result
 * @throws IOException
 */
@RequestMapping(value="login",method = RequestMethod.POST)
public String doLogin(User user, HttpServletRequest request, HttpServletResponse response,ModelMap map) throws IOException{
    if(!StringUtils.isEmpty(user.getName())){
        request.getSession().setAttribute(Constant.SESSION_USER_KEY,user);

        //login success, redirect to home controller, change the url also. if return viewName,can't change url.
        response.sendRedirect("/home");
        return null;
    }else{
        map.put("welcomeMsg",this.msg);
        return "login"; //login failure, return login page
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:23,代码来源:CommonController.java

示例9: doUndo

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
protected void doUndo(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException, SQLException {
	// TODO Auto-generated method stub
	String id = request.getParameter("Id");
       if (id != null && !id.trim().isEmpty()) {
       	int ID = Integer.parseInt(id);
       	int amount = saDAO.getAmount(COMPONENT, ID) - FIXEDVALUE;
       	saDAO.updateIncidentToPerson(id, amount, COMPONENT);
       }
       
       response.sendRedirect(LINKNAME);
}
 
开发者ID:qianyilun,项目名称:Queue-Manager-Cloud-Dispatcher,代码行数:14,代码来源:PersistenceWithSA.java

示例10: doGet

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
protected void doGet( HttpServletRequest req, HttpServletResponse resp )
		throws ServletException, IOException {
	String oper=req.getParameter( "oper" );
	if( log.isDebugEnabled() ) {
		log.debug( "oper=" + oper );
	}
	
	DecisionEntitlementHandler handler=getHandler( req );
	req.setAttribute( "handler", handler );
	
	if( "loadEntitlements".equals( oper ) ) {
		WebUtil.forward( req, resp, "/ralasafe/privilege/decisionEntitlementTable.jsp" );
		return;
	} else if( "getEntitlement".equals( oper ) ) {
		int index=WebUtil.getIntParameter( req, "index", -23 );
		if( index>=0 ) {
			DecisionEntitlement entitlement=(DecisionEntitlement) handler.getDecisionEntitlements().get( index );
			req.setAttribute( "entitlement", entitlement );				
		}
		
		WebUtil.forward( req, resp, "/ralasafe/privilege/editDecisionEntitlement.jsp" );
		return;
	} else if( "return".equals( oper ) ) {
		String gotoUrl="./nonRolePrivilegeMng.rls";
		if( handler.getPrivilege().getType()==0 ) {
			gotoUrl="./privilegeMng.rls";
		} 
		
		String key=getHandlerAttributeKey( req );
		req.getSession().removeAttribute( key );
		
		resp.sendRedirect( gotoUrl );
		return;
	} else {
		WebUtil.forward( req, resp, "/ralasafe/privilege/decisionEntitlement.jsp" );
		return;
	}
}
 
开发者ID:yswang0927,项目名称:ralasafe,代码行数:39,代码来源:DecisionEntitlementAction.java

示例11: doGet

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    HttpSession session = request.getSession();

    int logID = Integer.parseInt(request.getParameter("logID"));
    SchoolAccounts account = (SchoolAccounts) session.getAttribute("schoolAccount");
    SchoolLoginLogs loginLog = SchoolAccountDataAccessObject.getLoginLogByID(logID);

    if (loginLog != null) {
        List<SchoolActivityLogs> activityLogs = loginLog.getActivityLog();
        session.setAttribute("schoolActivityLogs", activityLogs);
    }
    response.sendRedirect("admin/admin-school-logs.jsp");
}
 
开发者ID:faizan-ali,项目名称:full-javaee-app,代码行数:14,代码来源:AdministratorSchoolSessionStatisticsServlet.java

示例12: render

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
public void render(HttpServletRequest request, HttpServletResponse response) throws RenderException {
    getContxtPath(request);
    String finalUrl = buildFinalUrl(request);
    try {
        response.sendRedirect(finalUrl);
    } catch (IOException e) {
        throw new RenderException(e.getMessage(), e);
    }
}
 
开发者ID:Xlongshu,项目名称:EasyController,代码行数:11,代码来源:RedirectView.java

示例13: doHeartbeat

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
public void doHeartbeat(HttpServletRequest request, HttpServletResponse response) {
  try {
    response.sendRedirect("ctrip_sso_heartbeat.html");
  } catch (IOException e) {
  }
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:8,代码来源:CtripSsoHeartbeatHandler.java

示例14: doPost

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	String party = request.getParameter("pname");
	String event = request.getParameter("ename");
	String page="";
	String sql="insert into event values('"+party+"', '"+event+"')";
	
	if(party.equals("") || event.equals(""))
	{
		page="Add_UpcommingEvent.jsp?msg=failure";
	}
	else
	{
		try
		{
			Model m =new Model();
			m.setParty(party);
			m.setEvent(event);
			
			int i = Dao.register(m,sql);
			if(i!=0)
			{
				page="Add_UpcommingEvent.jsp?msg=success";
			}
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		response.sendRedirect(page);
	}	
}
 
开发者ID:nishittated,项目名称:OnlineElectionVotingSystem,代码行数:32,代码来源:AddEvent.java

示例15: login

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * 处理从QQ到12345网站的单点登录
 *
 * @param response
 * @return
 * @throws Exception
 */
@RequestMapping("/qqLogin")
public void login(HttpServletResponse response) throws Exception {
    try {
        String redirect_url = "https://graph.qq.com/oauth2.0/authorize?" +
                "client_id=" + SSOCommon.qqAppKey +
                "&redirect_uri=" + SSOCommon.qqRedirectUri +
                "&response_type=code" +
                "&state=" + RandomStringUtils.randomAlphanumeric(10) +      //设置为简单的随机数
                "&scope=get_user_info";
        response.sendRedirect(redirect_url);
    } catch (Exception e) {
        logger.error("调用QQ接口异常!", e);
    }
}
 
开发者ID:Zephery,项目名称:newblog,代码行数:22,代码来源:IndexController.java


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