点集贵州电脑网
 
 
 梦想之源 ›› 灌水专区 ›› T4项目中的tomcat服务器重新启动出现的问题 版主:
灌水专区
新建论坛
申请免费TS
1 / 1 页
<< 1 >>
跳转
 主题:T4项目中的tomcat服务器重新启动出现的问题
 
 lele
发表时间:[2008-01-09 16:39:44] [向作者发站内短信] [复制链接告诉朋友]
等 级:列兵
经 验:498
性 别:帅哥
文 章:138
精 华:0

tomcat服务器重新启动出现的问题

 

问题描述:

首先 当前页面是A.,其上有链接 <a href="B.html" >查看</a>

然后重新启动tomcat

当前A页面不关闭

之后在tomcat完全启动后

在点A页面上的"查看" 链接

这个时候,查看后的页面B能打开 ,但是B页面的session失效

我希望的是:

在重新启动tomcat后,在点查看,应该出现的是登陆页

上次请教过,配置如下:

<contribution configuration-id="tapestry.InfrastructureOverrides">
  <property name="staleSessionPageName" value="LoginForSession" />
  <property name="staleLinkPageName" value="Login" />
 </contribution>

这个是配置session过期的


 楼主更多新贴 :  
灌水专区jfreechart图形上的链接
灌水专区itemselection的问题
灌水专区ognl:devicegroup.id
灌水专区foreach的问题
  楼1  
等 级:下士
经 验:1682
性 别:帅哥
文 章:496
精 华:2
 干煸四季豆
发表时间:[2008-01-09 20:32:22] [向作者发站内短信] [复制链接告诉朋友]

tapestry里面的session过期,是指如directlink,form这种它自己校验session的操作。如果是你自己需要校验session的页面,那么需要自己判断,其实也很容易,获取visit对象,看看你们useId是否为null,然后跳转到相应的页面即可。

一般使用pageValidateListener作为判断监听,因为这个接口的方法优先予页面类中的其它方法。

  楼2  
等 级:列兵
经 验:498
性 别:帅哥
文 章:138
精 华:0
 lele
发表时间:[2008-01-10 09:15:24] [向作者发站内短信] [复制链接告诉朋友]

 

在.page对应页面类中加入

public void pageValidate(PageEvent currentPageEvent) {
 
 
}

我想在这个方法里判断当session里的用户id为空时,跳转到Login页面

现在这个接口的方法返回类型是void,如何跳转呢,记得有个激活页面的方法 今天忘记带书了

请帮我看看

  楼3  
等 级:列兵
经 验:498
性 别:帅哥
文 章:138
精 华:0
 lele
发表时间:[2008-01-10 09:18:55] [向作者发站内短信] [复制链接告诉朋友]


 // 得到session对象
 @InjectState("SessionImplPO")
 public abstract SessionImplPO getPrivilegeResult();

 

 

 /**
  *
  */
public void pageValidate(PageEvent currentPageEvent) {
 
 if(null==getPrivilegeResult().getUserid()){
  //跳转页面Login
 }
}

 

 

 

  楼4  
等 级:列兵
经 验:498
性 别:帅哥
文 章:138
精 华:0
 lele
发表时间:[2008-01-10 09:20:53] [向作者发站内短信] [复制链接告诉朋友]

PageRedirectException

是否是因为会抛出这个感异常 在这个异常里处理跳转的页面

  楼5  
等 级:列兵
经 验:498
性 别:帅哥
文 章:138
精 华:0
 lele
发表时间:[2008-01-10 09:49:24] [向作者发站内短信] [复制链接告诉朋友]

public void pageValidate(PageEvent currentPageEvent) {
 logger.info("[pageValidate]页面过期事件监听中");
 logger.info("[session是否过期]"+(null==getPrivilegeResult().getUserid()));
 if(null==getPrivilegeResult().getUserid()){
  
  throw new PageRedirectException("pageValidate");
 }
}

这样确实可以完成过期后的跳转,但是又出现了一个问题

那就是:

在跳转后的pageValidate页面,该页面实现重新登陆,这个时候输错误的用户名和密码,系统不会跳转到出错误页面了,只有输正确的用户名和密码才可以跳转到主页

页面如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>BrowseView</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="keywords" content="" />
<meta name="description" content="" />

<link href="style/style.css" rel="stylesheet" type="text/css"/>

<script language="JavaScript">
document.oncontextmenu=new Function("event.returnValue=false;"); //禁止右键功能,单击右键将无任何反应
document.onselectstart=new Function("event.returnValue=false;"); //禁止先择,也就是无法复制
</script>

<script language=JScript defer type='text/javascript'>
function window.onload(){
  document.ondragstart = new Function('return false;');  //拖
  document.oncontextmenu = new Function('return false;'); //右键
  document.onselectstart = new Function('return false;'); //选
}
</script>
<script>
var flag=true;
function validatePW(){
if(document.getElementById("p").value==""||document.getElementById("p").value==null||document.getElementById("w").value==""||document.getElementById("w").value==null){
alert("用户ID和密码不能为空,请您重新登陆");
flag=false;

}
else{
flag=true;
}
return flag;

}
</script>
<style>
</style>
</head>
<body id="loginBg">
<div id="containerLogin">
<div id="loginTopBg">
  <div id=siteName1>
   <div id=logo1><a class=logo href="#"></a></div>
  </div>
   <div id="LoginTitle">登录区</div>

</div>

<div id="loginBodyBg">
 <form jwcid="loginForm" >
 <ul id=signIn>
  <li>没有登陆或者登陆超时,请重新登陆</li>
  <li>用户名:<label><input class=searchinput id=p name="username" jwcid="username"></input></label></li>
  <li>密 码:<label><input class=searchinput id=w name="password" jwcid="password"></input></label></li>
  <li><label><input name="登录" type="submit" value="登录" class="button" onclick="return validatePW();"></input></label> </li>
 </ul>
 </form>
</div>

</div>
</body>
</html>

 

.page如下:

<?xml version="1.0" encoding="GB2312"?>
<!DOCTYPE page-specification PUBLIC
  "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
  "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
<page-specification class="com.longcredit.KEye.app.business.LoginPage">
   
    <component id="loginForm" type="Form">
        <binding name="listener" value="listener:loginSubmit"/>
    </component>
   
    <component id="username" type="TextField">
        <binding name="value" value="username"/>
    </component>
   
    <component id="password" type="TextField">
        <binding name="value" value="password"/>
        <binding name="hidden" value="true"/>
    </component>
   
</page-specification>

  楼6  
等 级:列兵
经 验:498
性 别:帅哥
文 章:138
精 华:0
 lele
发表时间:[2008-01-10 10:05:19] [向作者发站内短信] [复制链接告诉朋友]

我觉得这样写之后,session过期是能判断出来,后台能打印出来,但是只要是退出(清sessiion了),重起服务器等操作都是session过期了,这样都会跳转到重新登陆页面,包括登陆错误的时候要跳转到的错误页面 也成了这个重新登陆页面了 这样怎么处理呢 

  楼7  
等 级:列兵
经 验:498
性 别:帅哥
文 章:138
精 华:0
 lele
发表时间:[2008-01-10 10:07:56] [向作者发站内短信] [复制链接告诉朋友]

登陆出错的我是 在登陆的方法 里 捕捉异常 进行跳转的

  } catch (Exception e1) {
   //当登录用户不存在的时候,该转向异常被触发
   throw new PageRedirectException("LoginFail");


  }

因为 这个方法里 if else太多就不铁出来代码了  主要就是这行代码

现在就是不跳转

  楼8  
等 级:下士
经 验:1682
性 别:帅哥
文 章:496
精 华:2
 干煸四季豆
发表时间:[2008-01-10 11:13:55] [向作者发站内短信] [复制链接告诉朋友]

不要用PageRedirectException进行跳转,Tapestry对这个异常的处理,是校验session的。下面是Tapestry处理PageRedirectException的代码,注意红色标注:

 /**
     * Handles {@link PageRedirectException} which involves executing
     * {@link IRequestCycle#activate(IPage)} on the target page (of the exception), until either a
     * loop is found, or a page succesfully activates.
     * <p>
     * This should generally not be overriden in subclasses.
     *
     * @since 3.0
     */

    protected void handlePageRedirectException(IRequestCycle cycle, PageRedirectException exception)
            throws IOException
    {
        List pageNames = new ArrayList();

        String pageName = exception.getTargetPageName();

        while (true)
        {
            if (pageNames.contains(pageName))
            {
                pageNames.add(pageName);

                throw new ApplicationRuntimeException(EngineMessages.validateCycle(pageNames));
            }

            // Record that this page has been a target.

            pageNames.add(pageName);

            try
            {
                // Attempt to activate the new page.

                cycle.activate(pageName);

                break;
            }
            catch (PageRedirectException secondRedirectException)
            {
                pageName = secondRedirectException.getTargetPageName();
            }
        }

        renderResponse(cycle);
    }

你可以使用RedirectException进行跳转,Tapestry对这个异常的处理不校验session,如下:

/**
     * Invoked when a {@link RedirectException} is thrown during the processing of a request.
     *
     * @throws ApplicationRuntimeException
     *             if an {@link IOException},{@link ServletException}is thrown by the redirect,
     *             or if no {@link RequestDispatcher}can be found for local resource.
     * @since 2.2
     */

    protected void handleRedirectException(IRequestCycle cycle, RedirectException redirectException)
    {
        String location = redirectException.getRedirectLocation();

        if (LOG.isDebugEnabled())
            LOG.debug("Redirecting to: " + location);

        _infrastructure.getRequest().forward(location);
    }

看到了吧?RedirectException是直接被request.forward的。

1 / 1 页
<< 1 >>
跳转
  快速回复
  帐号: 密码: 匿名不登陆
回复内容:  
验 证 码:
 
 
·9800GT+19'液晶DIY仅售3500元
·双核特惠:1999、2999、3999
·什么是点金积分,如何查看自
·团购一期:三星R458-DS0G+高
·抽奖活动已结束,感谢大家支
  
贵州点集科技发展有限责任公司·点集贵州电脑网 版权所有©2006-2008
中华人民共和国增值电信业务经营许可证 黔B-20070010号
客服QQ: 93804809818866281927205370
电子邮件: deangi@vip.sina.com
技术支持: 0851-5109268