Win a copy of Succeeding with AI 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
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

pass the session variable to 2 jsp simultaneously

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 1 servlet and 2 jsp fils(say a.jsp , b.jsp ) , one jsp( b.jsp) is embeded in the other jsp( a.jsp ) by using <IFRAME > Tag .
After servlet has finished its job ( save results as session variable ) , it use getRequestDispatch("a.jsp" ).forward(req,res ) to redirect the request to a.jsp . Does both a.jsp and b.jsp can access the same session variables ?
My situation is a.jsp can retrieve the session variable , b.jsp can access too , but it seems that data is corrupted ( In my situation , my session variable is a byte[] )
Thanks
ZY
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your two jsp can certainly share a session, but since you can't control the order in which the request threads run, you will need to synchronize access to any variables that might be changed.
Bill
------------------
author of:
 
Anderson gave himself the promotion. So I gave myself this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic