The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
July 2001



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.


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

Posted by RC on September 26, 2001 at 3:17 PM

Servlet Context parameters are different from
individual servlet parameters.

The former is specified as a tag accessible
to all servlets within your web application.

The latter is used embedded as a tag accessible
ONLY to your servlet as specified within the tag.

You have confused the two.

- RC

> 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:

> testServlet

> testServlet

> param1
> junk


> 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 "" 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!


Sponsored Links

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