You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Karina Anderson <ka...@unitechsys.com> on 2001/02/01 23:00:26 UTC
problems with servlet init parameters tomcat 3.2.1
I have a servlet that is trying to get inititalization parameters. I
have done all the doc says, but it doesn't get them. It gets null.
I am using tomcat 3.2.1 and jdk1.3.
My servlet is under
jakarta/webapps/DashboardDIG/Web-inf/classes/package.servlet.class
/web.xml
my web.xml has the following in it:
<servlet>
<servlet-name>myServlet</servlet-name>
<servlet-class>package.myServlet </servlet-class>
<init-param>
<param-name>tcpip</param-name>
<param-value>127.0.0.1</param-value>
</init-param>
<init-param>
<param-name>port</param-name>
<param-value>50000</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>
myServlet
</servlet-name>
<url-pattern>
/myServlet
</url-pattern>
</servlet-mapping>
I have a context entry in the /conf/server.xml file:
<Context path="/DashboardDIG"
docBase="/webapps/DashboardDIG"
crossContext="false"
debug="0"
reloadable="true" >
</Context>
My servlet has the following code to get the parameters:
public void init(ServletConfig config) throws ServletException
{
super.init(config);
log ( "Initializing AppletToDigServlet..." );
dbrdAddr = config.getServletContext().getInitParameter("tcpip");
temp = config.getInitParameter("port");
if (dbrdAddr == null)
{
log("error tcpip :" + dbrdAddr);
log("using default tcpip");
dbrdAddr = new String("127.0.0.1");
}
if (temp == null)
{
log("error port :" + temp);
log("using default port");
temp = new String("50000");
}
dbrdPort = new Integer(temp);
}
I don't get any of the parameters. Please anyone, what am I doing
wrong?
I am calling the servlet from an applet with the following call:
URL url = new
URL(http://localhost:8080/DashboardDIG/servlet/package.myServlet);
URLConnection con = url.openConnection();
con.setUseCaches(false);
con.setRequestProperty("CONTENT_TYPE","application/octect-stream");
con.setDoInput(true);
I have tried calling it with
http://localhost:8080/DashboardDIG/myServlet but I get 404, not found.
http://localhost:8080/DashboardDIG/package.myServlet but I get 404.
I don't think the mapping is working, and that's maybe the problem.
Please help,
Karina