This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Struts init()  RSS feed

 
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Am new to struts. I like to know where to load the properties file.. In servlet we have init() to load the properties. Similarly please suggest me where to load in Struts
 
Sheriff
Posts: 9643
42
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can load it in the constructor...
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Constructor ?. Which Constructor ?.

I guess better option is to extend the Action Servlet

After extending in the web.xml

<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>

Instead ActionServlet I configured my servlet I mean suclass of ActionServlet, am unable to start tomcat. Please help
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, ActionServlet should almost never need to be modified.

What kind of properties are you trying to load? Why not do it outside of the Struts framework in an application context listener or initialization servlet? If you *must* do it in Struts, use a plugin.
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just extended the TilesRequestProcessor and added my property file loading and log file initialization in the init() and everything works fine.

Modified struts-config.xml

Instead of <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>

added
<controller>
<set-property property="processorClass" value="MyProcessor"/>
</controller>

Could you please tell me whether am on the rite path.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really--why change something you don't have to when there are already mechanisms in place that don't require work elsewhere?
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please assist me, where I can place this code.

Some application specific properties and log initialization file creation.. etc.. I need do to these things in application startup.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What was wrong with the suggestions I already gave?

(And what log file configuration are you doing? Why not just let the logging framework handle that?)
 
Blueberry pie is best when it is firm and you can hold in your hand. Smell it. And smell this tiny ad:
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!