tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Felix A. Milovanov" <fe...@terasystems.com>
Subject Am I crazy???
Date Tue, 10 Apr 2001 00:48:14 GMT
  Hello all,

  now I start using Tomcat and servlet/JSP programming. I was need to make some
activity BEFORE invoking any servlet/JSP. I've created a very simple class :

import java.io.*;
import java.sql.*;
import java.lang.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;

public abstract class baseServlet extends HttpServlet implements HttpJspPage
{

  public void _jspService(HttpServletRequest Req, HttpServletResponse Res) 
         throws ServletException, IOException {}
  
  public void jspInit() {}
  public void jspDestroy() {}

  public void service(HttpServletRequest Req, HttpServletResponse Res)
         throws ServletException, IOException
  {
    String Path = Req.getServletPath();

    System.out.println("URL called : " + Path);
    
    /* Invoke original handler */
    if (Path.endsWith(".jsp")) _jspService(Req, Res);
                         else  super.service(Req, Res);  
  }
  

}

  I can inherit any servlet/JSP from this class, and now I just print to 
console the URI of requested WEB resource.

  Ok, everything works. Then I tried to handle error 404 with Tomcat - I've
already described 404 handler for apache :

ErrorDocument 404 /404.jsp

  /404.jsp works excellent, but when I tried to run something non-existed
URI like "/servelt/bla-bla-bla", I got an error from Tomcat instead of 
/404.jsp. Ok, I read the documentation and found how it should be done:

<web-app>
 <error-page>
  <error-code>404</error-code>
  <location>/404.jsp</location>
 </error-page>
</web-app>

  For now these lines are all in my web.xml. I've restarted tomcat, tried
to access /servlet/hmm and got the following message ( insted of my
own /404.jsp ) :

Error: 400
Location: /servlet/hmm
HTTP method GET is not supported by this URL

  The most strange issue is... I'VE GOT MESSAGE "URI called : /servlet/hmm"
ON THE CONSOLE!!! 

  I do not understand anything... WHY MY CODE IS INVOKED??? 

  Sincerely,
							Felix.

Mime
View raw message