• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How can i read init params in Struts Action?

 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends,

Just like we use init parameter in servlet and read it in servlet class through getInitParameter.

I want to read email(init parameter) form a .xml file(i.e. i would like to change it in future) in struts framework ???

Is there any alternative way in struts to read init parameter in my action ??

Please reply..

Thanks
[ December 28, 2007: Message edited by: Bear Bibeault ]
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An Action contains a reference to an ActionServlet which extends HttpServlet and has the getInitParameter method.
 
Rahul Nair
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Joe Ess:
An Action contains a reference to an ActionServlet which extends HttpServlet and has the getInitParameter method.




Hi Joe Ess,

Thanks for reply..
Its a quite good solution for my problem....
But How can i trap(get) ActionServlet instance or anything else form which i can get HttpServlet ???

What is the effect, if i use Naming.lookup() method (JNDI) to read Env-Entry from my web.xml ???

Which is the efficient way OR Standard Way to access parameter form my web.xml either through getInitParameter or Naming.lookup method ???

Thanks
 
Rahul Nair
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Please Help me, If someone know About initparam ???
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

But How can i trap(get) ActionServlet instance or anything else form which i can get HttpServlet ???



Your action extends org.apache.struts.action.Action, correct? Action contains a reference to an ActionServlet. Invoking:

should do it.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String email = this.servlet.getInitParameter("email");

Above will retrive value of "email" init parameter configured in web.xml.
 
reply
    Bookmark Topic Watch Topic
  • New Topic