The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
July 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Using in web.xml for a servlet parameter in Tomcat 3.2.2?

Posted by mike on July 11, 2001 at 4:30 PM

Hello...

We are Using Tomcat 3.2.2 on SunOS 5.6.

I am trying to add a custom parameter to web.xml to be used as my servlet is initialized.
The relevant piece of web.xml looks something like this:

<servlet>
<servlet-name>
testServlet
</servlet-name>
<servlet-class>
testServlet
</servlet-class>
<init-param>
<param-name>param1</param-name>
<param-value>junk</param-value>
</init-param>
</servlet>


Within the servlet's init(), I am using something like the following to try to retrieve the value of this parameter:

public class testServlet extends HttpServlet {
public void init(ServletConfig config) throws ServletException
{
sc = config.getServletContext();

String p1Attribute = sc.getAttribute("param1"));
String p1InitParram = sc.getInitParameter("param1"));
}

The value returned is always null. Tried this with the example called "ServletParam.java" that comes with 3.2.2., and can't get that to work either.

Has anyone had any luck with this sort of thing? Thanks!



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us