Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Applet session sharing

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to pass the session to my applet.
Can I just put it in the code I use to call the applet?
Like this:


Or is that not safe enough?
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The applet has no access to the archive tag; you'll need to use a <param> tag instead so that the applet can read it using the Applet.getParameter method.
 
Tristan Van Poucke
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok

So when I do that i can add "jsessionid=..." to the urls of every servlet I call in the applet atleast for the GET methods.
How can I do this for PostMethod? This is what I have been trying, but it still uses a different session



Or is there a way of changing the session of the applet all together?
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally applets use the same cookies the browser uses, so the sessionid should be sent automatically without the applet code having to do anything about it. If that's not the case, then the HttpClient documentation leads me to believe that it's necessary to call method.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES) if you want to handle cookies manually.
 
Tristan Van Poucke
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm strange

I can't think of anything I do to change the default behaviour of the applet.

And it still uses another session...

Or could it be that the servlets, I call from the applet use a different session?

 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing to try would be to use a TCP/IP or HTTP monitor and check that the format used by the web pages and the applet for sending the sessionID is actually identical.
 
Tristan Van Poucke
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok

I have made some progress.

It seems that the servlet recieves the jsession cookie from the applet correctly.
But it just ignores it.

Could this have something to do with tomcat?
 
Tristan Van Poucke
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok

I found the solution,

apparently the parameter name should be uppercase.

Although almost every search I did, I came across jsessionid in Lowercase.

Stupid mistake I guess

Thank you for the help.
 
Did you ever grow anything in the garden of your mind? - Fred Rogers. Tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic