tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From S.Z...@spmv.de
Subject AW: When are classes loaded?
Date Tue, 22 Aug 2000 14:42:58 GMT
Hi,

I think you should put your

System.out.println("loading class Test1...");

into the init() method like:

public void init(ServletConfig conf) throws ServletException
{
	super.init(conf);
	System.out.println("loading class Test1...");
}

HTH,

Stephan

> When are classes loaded in Tomcat 3.2b2?  I've got the servlet in my
> mike/web_inf/classes directory.  When I start tomcat, 
> shouldn't I see the
> message "loading class Test1..."?  Should this only happen when it is
> called?
> 
> I'm really confused because I can't get such a simple servlet 
> to run and
> don't have any clue as to why.
> 
> (Windows 2000, JDK 1.2.2_006)
> 
> Thanks in advance...
> 
> 
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> 
> public class Test1 extends HttpServlet {
> 
>  static {
>   System.out.println("loading class Test1...");
>  }
> 
>  public void doGet(HttpServletRequest req, 
> HttpServletResponse res) throws
> ServletException, IOException {
>   System.out.println("running doGet on Test1");
>   res.setContentType("text/html");
>   PrintWriter out = res.getWriter();
> 
>   out.println("<html>");
>   out.println("<head>");
>   out.println("<title>");
>   out.println("Test1 Servlet");
>   out.println("</title>");
>   out.println("</head>");
>   out.println("<body>");
>   out.println("Hello World!");
>   out.println("</body>");
>   out.println("</html>");
> 
>  }
> }
> 

Mime
View raw message