You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Silviu Popescu <si...@yahoo.com> on 2007/11/11 11:13:10 UTC

web.xml file isn't read by server ( I think .. )

Hi,
  I am having the following problem:

  I'm trying to access some parameters (e.g: "message") defined in web.xml file but they are not seen in servlet class;
My servlet works fine in the rest.
(I invoke it : http://localhost/servlet/coreservlets.ShowMessage )

$CATALINA_HOME/webapps/ROOT/WEB-INF/classes/coreservlets/ShowMessage.class:

package coreservlets;
------------------------------
...output omitted...
------------------------------
public class ShowMessage extends HttpServlet {
  private String message;
  private String defaultMessage = "No message.";
  private int repeats = 1;
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
    message = config.getInitParameter("message"); // returns null
    if (message == null) {
      message = defaultMessage;
    }
------------------------------
 ...output omitted...
 ------------------------------

$CATALINA_HOME/webapps/ROOT/WEB-INF/classes/web.xml file:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">

<web-app>
  <servlet>
    <servlet-name>ShowMsg</servlet-name>
    <servlet-class>coreservlets.ShowMessage</servlet-class>
    <init-param>
      <param-name>message</param-name>
      <param-value>Shibboleth</param-value>
    </init-param>
    <init-param>
      <param-name>repeats</param-name>
      <param-value>5</param-value>
    </init-param>
  </servlet>
</web-app>

Thanks,
Silviu

 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: web.xml file isn't read by server ( I think .. )

Posted by Silviu Popescu <si...@yahoo.com>.
Thanks a lot.
You were right, I was using the invoker servlet. I've added the mappings and it worked.

Mark Thomas <ma...@apache.org> wrote: Silviu Popescu wrote:
> 
>   
>     ShowMsg
>     coreservlets.ShowMessage
>     
>       
message

>       
Shibboleth

>     
>     
>       
repeats

>       
5

>     
>   
> 

You don't appear to have a servlet mapping? Are you using the invoker
servlet? If so, the init parameters will have no effect.

Mark


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: web.xml file isn't read by server ( I think .. )

Posted by Mark Thomas <ma...@apache.org>.
Silviu Popescu wrote:
> <web-app>
>   <servlet>
>     <servlet-name>ShowMsg</servlet-name>
>     <servlet-class>coreservlets.ShowMessage</servlet-class>
>     <init-param>
>       <param-name>message</param-name>
>       <param-value>Shibboleth</param-value>
>     </init-param>
>     <init-param>
>       <param-name>repeats</param-name>
>       <param-value>5</param-value>
>     </init-param>
>   </servlet>
> </web-app>

You don't appear to have a servlet mapping? Are you using the invoker
servlet? If so, the init parameters will have no effect.

Mark


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org