• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

initialization parameters

Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
I'm trying to set initial value in a sevlet.
i'm using tomcat3.1,or jsdk2.
with Tomcat you have to create an xml file and set the name of the servlet and the name and the value of the parameter.
but there is a default web.xml file in web-inf.
do i have to just put a name for a file with extension xml and put it along with the default file(web.xml?
or i have to move that default file(web.xml) and put it somewhere and name my file web.xml and put it at that directory(web-inf).
really i do not know and that what i did,but i got just null.
that means something wrong and the that parameter doesn't exist.
here is the files:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"

here is the servlet file:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class initPara extends HttpServlet
private String initial;
public void init(ServletConfig config) throws ServletException
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException
PrintWriter out=res.getWriter();
here is my url: http://localhost:8080/examples/servlet/initParameter
thanks for your help.
William Brogden
Author and all-around good cowpoke
Posts: 13074
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The default web.xml should work for experimentation. As I understand it you only use the application specific web.xml files to specify parameters for those applications that may override the default. Double-check the spelling and the use of upper/lower case in your servlet name and class name.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic