chakri chakri - 1 year ago 130
Java Question

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. Please help me how to get those session values.

i set the some values to session like session.setAttribute("id", 120). After redirect the paymeny gateway. I try to get the id using session.getAttribute("id"). Here it returns the null value.

Answer Source

From chat, you had stated that you are keeping the JSP session ID in a URL parameter rather than a cookie. This will cause an issue with the callback from the payment gateway, if the callback URL does not specify the same session ID.

This means that you need to put the session ID in the callback URL. I am not familiar with CCAvenue as a payment gateway, but I can tell you this much:

When you set the callback URL, you need to encode the session ID onto it using HttpServletResponse#encodeURL

example and expanation here

You would pass the URL of the callback (i.e. your homepage) to this method, and it will return the callback URL with the session ID encoded within it, if necessary. 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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download