Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I read parameters from a file with Visual Age for Java?  RSS feed

John Cummins
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
<description>Test Servlet</description>
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) {
ServletOutputStream out = response.getOutputStream();
Enumeration keys;
String key = new String();
keys = request.getParameterNames();
while (keys.hasMoreElements())
key = (String) keys.nextElement();
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.
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!