Hi all, I need to call a text file (.txt) only one time in my servlet while servlet start (I meant init() method) which contains user info. From that I need to verify the user info in service or dopost method by referring the above text file irrespective of calling the text file everytime in the service method. Pls advise me.. how to achieve my task. Thanks Cheers jowsaki
Hi Sham It may be worth considering using initial parameters for your servlet, which you configure in your web application's deployment descriptor (web.xml) file using <init-param> tags. You then retrieve these parameters using the ServletConfig's getInitParameter("param name") method in your servlet's init() method. Hope this helps Mark.
Joined: May 22, 2001
Hi mark, Do i need to call below <web-app> <servlet> <servlet-name>Controller</servlet-name> <display-name>Controller</display-name> <servlet-class>ControllerServlet</servlet-class> <init-param> <param-name>ActionConfig</param-name> <param-value>config.txt</param-value> </init-param> </servlet> If it is correct pls advise me below points (a) where do i need to keep config.txt and (b)How can invoke the filereader object(above text file) in my service or dopost method. Pls advise me tks a lot jowsaki
Joined: Feb 14, 2001
Hi Sham What I meant was to use init parameters instead of an external file. Or does the file contain a lot of data too cumbersome to place in the deployment descriptor?
in any case, if you'll decide to use init params or text file, you don't have to punish the first user who will enter your servlet and will have to wait until your file will be read and the parameters will be run as you want. you can use <load-on-startup> tag and your servlet will be initialated and its init method will be called when your servlet will start.