Setting value to static variable at deployment time?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   kumaran_rajendran
Posted On:   Thursday, January 13, 2005 06:16 AM

Problem I am working on a product which is java based. I have a war file. In that war file I am having servlet and that servlet call other class in its init method. In that class there are some static variables and I wanted to set values for that variable at deployment time. Here is the code public class Start extends HttpServlet { public void init(ServletConfig config) throws ServletException { super.init(config); DB.loadProperties (); } // init public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } // doGet    More>>

Problem


I am working on a product which is java based. I have a war file. In that war file I am having servlet and that servlet call other class in its init method. In that class there are some static variables and I wanted to set values for that variable at deployment time.


Here is the code




			
public class Start extends HttpServlet
{

public void init(ServletConfig config) throws ServletException
{
super.init(config);
DB.loadProperties ();

} // init


public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
} // doGet



public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
} // doPost

} // Start

public final class DB implements Serializable
{
public static final String filename = "Application.pro";
public static boolean loadProperties ()
{
FileInputStream fis = null;
try
{
fis = new FileInputStream(filename);
…
}
catch (FileNotFoundException e)
{
…
}

}

…}




As you can see if I deployed this war it will look for "Application.pro” file. I wanted to change value of that variable at deployment time.


Restriction




I am not allowed change the code or logic of the product. I must be able to get some thing outside or apply a patch to solve this problem.




Please Help




Kumaran    <<Less
About | Sitemap | Contact