• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot Load Servlet Name: InitialMsg  RSS feed

 
matt yeh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, All:
I edit $TOMCAT_HOME/webapps/ROOT/WEB-INF/web.xml as following:
==============================
<?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>InitialMsg</servlet-name>
<servlet-class>test.InitialMessage</servlet-class>
<init-param>
<param-name>username</param-name>
<param-value>scott</param-value>
</init-param>
<init-param>
<param-name>password</param-name>
<param-value>manager</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>
============================================
and compile InitialMessage.java:
i.e.:
javac -d $TOMCAT_HOME/webapps/ROOT/WEB-INF/classes InitialMessage.java
"InitialMessage.java" as following:
===================================================
package test;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class InitialMessage extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
super.init(config);
ServletContext application = null;
String username = config.getInitParameter("username");
String password = config.getInitParameter("password");
application.setAttribute("username", username);
application.setAttribute("password", password);
}
}
=========================================================
But when I restart tomcat, it tells me:
"cannot load servlet name: InitialMsg: null"
Anybody knows why? Thanks a lot!! ^^
Vincent_Yeh

[This message has been edited by Vincent Yeh (edited July 05, 2001).]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that your class files ended up in the right place - ie:
WEB-INF\classes\test\InitialMessage.class
I would try putting some System.out.println statements in the init method.
Bill
 
matt yeh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Brogden:
Assuming that your class files ended up in the right place - ie:
WEB-INF\classes\test\InitialMessage.class
I would try putting some System.out.println statements in the init method.
Bill

Yes, it is right at WEB-INF\classes\test\InitialMessage.class
So I don't know why? :-(
Vincent_Yeh


[This message has been edited by Vincent Yeh (edited July 05, 2001).]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!