• 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

encodeURL problem

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I was trying to experiment with the use of encodeURL( String). I did the experiment with getSession() and encodeURL(). The code is shown and the problem is mentioned below the code.




It is found that if I use getSession() (As shown above. encodeURL is commented) , the execution goes to "else" part whenever I refresh the page. When I comment getSession() and include the encodeURL("." ) line, execution never goes to the else part..Could anybody point out the mistake.. I am using Tomcat 5.5 as my server.

thanks in advance

regards
sasikumar
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This problem is not related to encodeUrl, but with the way you are using getSession. Calling getSession() will return an existing session, or create a new one if it doesn't already exist. If you comment this out, no session will be created, so you'll always end up in the if{}. If you leave it, you'll end up in the else{} after the session has been created.
 
sasikumar palakkizhi
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Satou kurinosuke,

Thanks for the reply, I tried again.

I realised that encodeURL and getSession() works together to get the session information if the Cookies are disabled...

regards

sasikumar
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't see where you are declaring your the variable "session".
I'm assuming that it's in the service (doPost or doGet) method.

With every hit, you're testing the 'session' variable for nullness and then setting it's value it it's null. With this logic, it will always be null.

Call request.getSession before testing for nullness.
 
mooooooo ..... tiny ad ....
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic