This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Setting the path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Setting the path" Watch "Setting the path" New topic
Author

Setting the path

Rebecca Abraham
Ranch Hand

Joined: Feb 20, 2003
Posts: 37
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.
s penumudi
Ranch Hand

Joined: Nov 17, 2004
Posts: 113
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
 
wood burning stoves
 
subject: Setting the path
 
Similar Threads
Compiling jsp to servlet-Concept
WebsphereTestEnvironment problem
Struts + Applet
Absolute Paths
WebsphereTestEnvironment problem