| Author |
How do I read parameters from a file with Visual Age for Java?
|
John Cummins
Greenhorn
Joined: Jul 26, 2001
Posts: 5
|
|
I am new to servlets and need to write a servlet that can read certain parameters(database driver, etc.) from a file(i.e. abc.ini). I am using IBM VisualAge for Java 3.5.3 and I think I need to change the .webapp file but I am not sure to what. Any references to check or sample code would be much appreciated. I tried switching adding this to the end of the default_app.webapp file. <servlet> <name>Servlet1</name> <description>Test Servlet</description> <code>test.Servlet1</code> <servlet-path>/</servlet-path> <init-parameter> <name>myTest</name> <value>C:\java\test.ini</value> </init-parameter> <autostart>true</autostart> </servlet> I wrote a servlet that should just print out the names of all the paramters it gets, so I have both the doPost and doGet methods calling this method: public void performTask(HttpServletRequest request, HttpServletResponse response) { try { ServletOutputStream out = response.getOutputStream(); Enumeration keys; String key = new String(); keys = request.getParameterNames(); while (keys.hasMoreElements()) { key = (String) keys.nextElement(); out.println(key); } out.println("Hello World!"); } catch(Throwable theException) {} } All that prints out when I switch the code, is "Hello World", with no parameters. I can get parameters from an HTML page to show up, but still cannot get any parameters from a file to work. If anyone can give me any on-line references or sample code, I would be much obliged. Thanks.
|
John C. Cummins<br />Sun Certified Programmer for Java 2<br />Sun Certified Web Components Developer<br />IBM Certified WebSphere Portal 5 Developer
|
 |
Roy Ben Ami
Ranch Hand
Joined: Jan 13, 2002
Posts: 732
|
|
hi . well, in order to get parameters from the web.xml or the webapp to work, it will not pass in as the request. instead u need to get servletConfig using getServletConfig() and then call the getInitParameters(); hope thats what u wanted.
|
 |
 |
|
|
subject: How do I read parameters from a file with Visual Age for Java?
|
|
|