Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to access a bean in a servlet file?

 
Niu Xiuyuan
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use <jsp:useBean.... create a bean in a jsp file and set its scope to "session",when the file redirect to a servlet file,i don't know how use the instance of bean in the servlet?
 
Jeff Halleux
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that <jsp:useBean> action with a scope equals to "session" will put the object in the pageContext associated with the jsp page using a session scope. Therefore, this object is unavailable in the session object that you get with req.getSession() under a servlet.
Let's say you have defined an HttpSessionAttributeListener for the context, setting/unsetting session attributes in this context using jsp:setProperty will not fire any events either.
Rather ackward ain't it ?
Any comments ?
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!