表单提交时会话已过期
在一种情况下,我有一个表单,该表单从我的应用程序中显示为各种事件的动态弹出窗口。我正在填写表格并提交,这会导致会话过期。
我发现在表单中打印请求标头的值时,我发现 jsession id 丢失,或者有时会创建新的 jseesion id。
这种情况并不经常发生。在工作情况下,我没有丢失任何 jsession id 或获得不同的 jseesion id。
有什么建议吗?
下面是代码示例。
<HTML>
<HEAD>
</HEAD>
<%
Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements())
{
String headerName = headerNames.nextElement();
String headerValue = request.getHeader(headerName);
System.out.println("Header Name " +headerName );
System.out.println("headerValue " +headerValue );
}
%>
<body>
Comments </br>
<form name = 'savefrm' action ='save.jsp'>
<textarea name = 'comments' id = 'text' cols=38 rows=8>"+comments.trim()+"</textarea>
<input type="submit" value="ok"/>
</form>
</body>
</html>
There is a scenario in which I am having a form which is shown from my application as a pop up dynamically for various events. I am filling up the form and submitting it which causes session expiry.
I found out that when printing the values of the request headers in the form, i see that the jsession id is missing or sometimes new jseesion id is created.
This is not happening frequently. In working cases I am not missing any jsession id or getting differnt jseesion id's.
Any suggestions?
Below is the code sample.
<HTML>
<HEAD>
</HEAD>
<%
Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements())
{
String headerName = headerNames.nextElement();
String headerValue = request.getHeader(headerName);
System.out.println("Header Name " +headerName );
System.out.println("headerValue " +headerValue );
}
%>
<body>
Comments </br>
<form name = 'savefrm' action ='save.jsp'>
<textarea name = 'comments' id = 'text' cols=38 rows=8>"+comments.trim()+"</textarea>
<input type="submit" value="ok"/>
</form>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该通过 web.config 设置会话超时,如下所示:
1000 毫秒 = 1 秒
You should set your session timeout through web.config like this:
1000 ms = 1 second
在 web.xml 文件上:
20 = 20 分钟
或者您可以在代码中执行此操作:
20 * 60 = 20 分钟
On web.xml file :
20 = 20 minutes
Or you can do it inside the code :
20 * 60 = 20 minutes