[英]I am losing session data when being redirected from Payment GateWay using java
I am setting some values using java session. After calling the Payment gateway, all me stored session values are losing.我正在使用 java session 设置一些值。调用支付网关后,我存储的所有 session 值都丢失了。 Please help me how to get those session values.请帮助我如何获得那些 session 值。
i set the some values to session like session.setAttribute("id", 120).我将一些值设置为 session,例如 session.setAttribute("id", 120)。 After redirect the paymeny gateway.重定向支付网关后。 I try to get the id using session.getAttribute("id").我尝试使用 session.getAttribute("id") 获取 id。 Here it returns the null value.在这里它返回 null 值。
From chat, you had stated that you are keeping the JSP session ID in a URL parameter rather than a cookie. 在聊天中,您已经声明要在URL参数而不是cookie中保留JSP会话ID。 This will cause an issue with the callback from the payment gateway, if the callback URL does not specify the same session ID. 如果回调URL未指定相同的会话ID,则这将导致付款网关的回调出现问题。
This means that you need to put the session ID in the callback URL. 这意味着您需要将会话ID放在回调URL中。 I am not familiar with CCAvenue as a payment gateway, but I can tell you this much: 我不熟悉CCAvenue作为付款网关,但是我可以告诉您很多:
When you set the callback URL, you need to encode the session ID onto it using HttpServletResponse#encodeURL
设置回调URL时,需要使用HttpServletResponse#encodeURL
在其上编码会话ID。
You would pass the URL of the callback (ie your homepage) to this method, and it will return the callback URL with the session ID encoded within it, if necessary . 您可以将回调的URL(即您的主页)传递给此方法,并且如有必要 ,它将返回带有在其中编码的会话ID的回调URL。 You can then use this URL as the user redirect (callback) on your gateway and when the redirect completes, the page will be loaded with a valid session. 然后,您可以将该URL用作网关上的用户重定向(回调),当重定向完成时,页面将加载有效的会话。
You need to add the JSESSIONID in the callback url something like the following:您需要在回调 url 中添加 JSESSIONID,如下所示:
HttpSession session = request.getSession();
session.setAttribute("someName", someObject);
String callbackURL = "http://yourapplicationserver.com/callback.jsp;JSESSIONID=" + session.getId();
String redirectURL = "http://paymentgateway.com/process?callbackURL=" + URLEncoder.encode(callbackURL, "UTF-8");
response.sendRedirect(redirectURL);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.