• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

How to load resources from my own file in struts

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am newbee to struts. Instead of ApplicationResources.properties file i would like 3/4 different files to be parsed and loaded into memory when my Tomcat starts up. How can this be acheived in struts?? Where do I write code for this???
Cheers
Jayram
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at this:
http://jakarta.apache.org/struts/api-1.0/org/apache/struts/util/package-summary.html#doc.Messages
 
jayram
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok i will rephrase my question ..
if i want to do certain tasks only once at startup how do i define them under struts
 
Marshal
Posts: 16440
272
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've never tried this but it would be one thing I might try if I had to do what you're asking.
Subclass ActionServlet and override the init() method to load the other properties files as ResourceBundles and keep these as private members (of course, I'd call super.init() before anything else). I would also look into whether it would be more appropriate to override one of the initXXX() support methods of ActionServlet.init() to make the specialization more fine-grained.
Then make any necessary changes to struts-config.xml and other startup files.
HTH,
Junilu
 
jayram
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well i extended the class as MyActionServlet and now init() method is overridden. Now i get the following exception when i try to execute.
javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE
Any ideas?
Cheers
Jayram
 
Junilu Lacar
Marshal
Posts: 16440
272
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you remember to call super.init() ?
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another option is to write a servlet that performs the startup tasks you need, and then put it into your web.xml and set it to run at start-up.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jayram, I'd suggest examining Struts Plugins. Im my opinion they are the best option for your task. Anything you would like to load on startup can be done so using a plugin. They are called whenever the container starts the web application.
Selim
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FYI, the date on these posts are back in 2002...
 
No. No. No. No. Changed my mind. Wanna come down. To see this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic