Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Servlet/JSP/JSF/JavaFX Script  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
reply to postflat modethreaded modego to previous topicgo to next topicgo to back
作者 Servlet Filter做验证 转向功能不起作用
blueoxygen





发贴: 31
于 2005-05-09 18:03 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
配置等都没有问题 因为受限目录确实得到了保护 但是,问题时,无法访问的时候我设计的是转向另外一叶,但是现在情况时一片空白,就是阻止访问之后没有动作了 请问原因
codes r here:

package com.jspdev;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class SignonFilter implements Filter{
final private String LOGIN_PAGE= "http://www.sina.com.cn";
protected FilterConfig filterConfig;
/* (non-Javadoc)
* @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
*/
public void init(FilterConfig config) throws ServletException {
// TODO Auto-generated method stub
this.filterConfig = config;
}

/* (non-Javadoc)
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
HttpServletRequest hreq = (HttpServletRequest)req;
HttpServletResponse hres = (HttpServletResponse)res;
String isLogin = "";
HttpSession session = hreq.getSession();
try{
isLogin = session.getAttribute("isLogin").toString();
if(isLogin.equals("ture"))
{
System.out.println("access valid");
chain.doFilter(req,res);
}
else{
hres.sendRedirect(LOGIN_PAGE); //就是此处转向的
}
}
catch(Exception e)
{
e.printStackTrace();
}
}

/* (non-Javadoc)
* @see javax.servlet.Filter#destroy()
*/
public void destroy() {
// TODO Auto-generated method stub
this.filterConfig = null;
}
public void setFilterConfig(final FilterConfig filterConfig)
{
this.filterConfig = filterConfig;
}


blueoxygen edited on 2005-05-09 18:06

i'll be a happy designer

致JAVA初学者+如何下手学JAVA

话题树型展开
人气 标题 作者 字数 发贴时间
3021 Servlet Filter做验证 转向功能不起作用 blueoxygen 2252 2005-05-09 18:03
3094 Re:Servlet Filter做验证 转向功能不起作用 bluepure 646 2005-05-09 19:30
2839 Re:Servlet Filter做验证 转向功能不起作用 blueoxygen 48 2005-05-10 09:12

reply to postflat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923