This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

context variable in action servlet  RSS feed

 
jacob deiter
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My application is based on struts 1.2 and spring.I have a context variable ctx which is to be initialized when application starts and used in all action class.For that, context variable is to be declared in Action servlet and used in all action
[ July 04, 2008: Message edited by: jacob deiter ]
 
Siddharth Naik
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Initialize context attributes in ServletContextListener and not in any action class. During initialization of servlet context attributes, you can use context parameters specified in web.xml
 
jacob deiter
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply.Could you please some pseudo code
 
jacob deiter
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jacob deiter:
Thanks for reply.Could you please give some pseudo code
 
Siddharth Naik
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Siddharth Naik
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh and don't forget to register your listener in web.xml

 
jacob deiter
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my application business service contain only business logic.It never contain session object and other stuff.It may fit into standalone application also.What ever input given to business layer ,thru its input parameter only.So i have pass the context variable in every method.If it so ,why I have to do the pass the again and again.Is there any good approach

Thanks in advance
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!