本文整理匯總了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;
}
示例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);
}
}
示例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");
}
示例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");
}
示例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;
}
示例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");
}
}
示例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);
}
}
}
示例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
}
}
示例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);
}
示例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;
}
}
示例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");
}
示例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);
}
}
示例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) {
}
}
示例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);
}
}
示例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);
}
}