File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes context variable in action servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "context variable in action servlet" Watch "context variable in action servlet" New topic
Author

context variable in action servlet

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
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

Joined: Apr 09, 2006
Posts: 35
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


Thanks<br />Sid
jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
Thanks for reply.Could you please some pseudo code
jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
Originally posted by jacob deiter:
Thanks for reply.Could you please give some pseudo code
Siddharth Naik
Ranch Hand

Joined: Apr 09, 2006
Posts: 35
Siddharth Naik
Ranch Hand

Joined: Apr 09, 2006
Posts: 35
Oh and don't forget to register your listener in web.xml

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: context variable in action servlet