request.getSession()在sendRedirect()之后创建新会话 [英] request.getSession() creating new session after sendRedirect()

查看:328
本文介绍了request.getSession()在sendRedirect()之后创建新会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发旅游应用程序。通过这次航班,预订酒店,巴士车票。它是基于产品的应用程序。我们几乎有25个客户(3个客户正在使用,剩余仍在开发中)。我们为所有客户维护一台服务器。一个服务器(应用程序)多个客户端是我的应用程序中的重大成就。但问题是每个客户都有不同的支付网关进行汇款,如EBS,HDFC,ICICI,ATOM等。我们必须使用sendRedriect()来呼叫他们的支付网关系统。

We are developing travel application. Through this flight, Hotel, Bus tickets will be booked. It is product based application. Nearly we have 25 clients(3 clients are using, for remaining still developing). We are maintaining one server for all clients. One server(application) multiple clients is the great achievement in my application. But the problem is every client is having different payment gateways for their money transfer like EBS, HDFC, ICICI, ATOM etc. We have to use sendRedriect() to call their payment gateway system.

response.sendRedirect("hdfc link....");

在重定向之前,我们在会话范围内存储了近7-9个对象,每个对象将包含近35个-50变量。
完成支付网关流程后,将重定向到我的应用程序。当我试图获得会话时

before redirecting we are storing nearly 7-9 objects in session scope, and each object will contain nearly 35-50 variables. After completion of the payment gateway process that will be redirected to my application. When i try to get the session

request.getSession();

它创建了一段新会话(10次中有5次)。

it is creating new session for some times(5 out of 10 times).

存储在请求范围内的变量对我来说至关重要。并且我无法将其存储到数据库中,因为它们非常庞大。对于每个请求,我们生成长度为25的随机数。使用该随机数存储会话变量。

The variables which are stored in request scope are crucial for me. and i cant store it into database because they are very huge. For every request we are generating random number whose length is 25. With that random number the session variables are stored.

session.setAttribute("flightStatus"+randomNumber, flightstatus object); 

因此,请建议如何取回上一个会话,以及为什么上一个会话无效和新会话正在创建。

So please suggest how to get back the previous session, and why the previous session is invalidated and new session is getting create.

推荐答案

我认为你应该使用request.getSession(false)。如果您不想参加新会话。

I think you should use request.getSession(false) . If you don't want to get new session.

阅读本文档: request.getSession(false)

这篇关于request.getSession()在sendRedirect()之后创建新会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆