• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

cannot get session variables

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello to all.

I am developing a shopping cart application in which I use to store some session variables in session object.
The problem arise when I integrate paypal with my application.
I use following code to redirect to the paypal's site

When I return from the paypal's site my all session variables are nulled.
I read somewhere that "response.sendRedirect()" method kills the session.
So, please somebody suggest me the alternatives of this method so that I cannot lose my session.

Thank You
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

rajshkhr pandey wrote:When I return from the paypal's site my all session variables are nulled.



session cant be share between two different applications

rajshkhr pandey wrote:
I read somewhere that "response.sendRedirect()" method kills the session.


No. with in an application,you can access the session
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JSESSIONID which is your session identifier is normally transmitted back and forth from the browser to the server using a cookie. If cookies are turned off at the browser, this (the JSESSIONID) needs to be transmitted via the url (this technique is called url rewriting). To achieve this, there are 2 methods in the HttpServletResponse api - encodeURL and encodeRedirectURL. You should treat all urls (links and form posts urls) with these methods and it would determine if url rewriting is needed and encode the url appropriately.

You can use a FF plugin like Live HTTP Headers which will show you all the artifacts that goes in a request (and all that comes back in a response) - cookies, headers etc.

Does your application work normally otherwise without any need for url rewriting? I believe sites like paypal redirect the user back to your website after processing payments. Examine the difference between normal requests and the redirect that comes from the payment site (using the tool I mentioned earlier). You should be able to figure it out yourself from there.

cheers,
ram.

 
rajshkhr pandey
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for you reply,

seetharaman venkatasamy wrote:
session cant be share between two different applications


I am not sharing session between my application and paypal
I am only doing
1. storing my required session variables at my side in session object (eg. Item Name,Item Number, User Id etc).
2. Redirecting to the paypal's website.
3. Logs in payapl's website, it returns me a token
4. I use that token for further check out.

The problem arise between step three and four, where when I want to retrieve my session variable it shows null value.


seetharaman venkatasamy wrote:
No. with in an application,you can access the session


but I cannot access it and I think because of response.sendRedirect()
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

rajshkhr pandey wrote:

seetharaman venkatasamy wrote:
No. with in an application,you can access the session


but I cannot access it and I think because of response.sendRedirect()



did you test?write a small program to test
 
rajshkhr pandey
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

seetharaman venkatasamy wrote:
did you test?write a small program to test


Yes I have made a small program and used response.sendRedirect() method and surprisingly I am getting my session variables.

So it might be problem in setting session variable in my application
I will search it out.
Thanks.
 
rajshkhr pandey
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your efforts to solve my problem.

I have solved my problem. It was session which gets expires between I return from the paypal's site so I set its max time to expire by the function setMaxInactiveInterval() in javax.servlet.http.HttpSession object and I get all my session varaibles that I have stored.

Thanks Again
 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic