• 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

Setting the path

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

I have a doubt in my application. The flow is as follows : When my appln starts a servlet is loaded and a jsp is displayed. On a particular event in the jsp an Action class is called from where my java class is invoked. In this java class, I have hardcoded the folder path of an API . I want to avoid the hard coding. I tried giving it in the init param of web.xml but the value appears "null" in my java class. However the value is obtained in the servlet, while the application is loaded.
Can u tell me what is wrong? or suggest a work around for removing the hardcoding.

Thanks.
 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess your java class is just a POJO. It cannot access any of the servlet related objects. Hence you cannot access InitialContext.

Work around would be pass that path from your Action class to your java class as method parameter

You can make use of properties file but I guess even I this case you have to hardcode the location where your property file reside. But path which you have hardcoded would be changed at runtime.

I can think of only these solutions now. Hope this helps
 
God is a comedian playing for an audience that is afraid to laugh - Voltair. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic