Actually this is very easy; when you want to pass the request down the
chain (i.e. into the servlet) you call the chain.doFilter() method. When
you *don't* want the request passed on, your filter just sets up the
response (status, header, etc.) and returns.

André Warnier <a...@ice-sa.com> wrote on 12/19/2008 02:50:25 PM:

> Ken Bowen wrote:
> > Of course, Google is your friend:
> >      Results 1 - 10 of about 237,000 for hello world servlet. (0.23
> > seconds)
> > :-)
> >
> Yeah, I got that too.
> That's the problem though : which one to choose ?
>
> Never mind, and apologies, I think I'll use the first one :
>
> package test;
>
> import java.io.*;
>
> import javax.servlet.http.*;
> import javax.servlet.*;
>
> public class HelloServlet extends HttpServlet {
>    public void doGet (HttpServletRequest req,
>                       HttpServletResponse res)
>      throws ServletException, IOException
>    {
>      PrintWriter out = res.getWriter();
>
>      out.println("Hello, world!");
>      out.close();
>    }
> }
>
>
> But now, a trickier question :
>
> I already have a servlet filter, in front of a servlet which I need
anyway.
> Can I, in the filter, and based on some characteristic of the request,
> return a response to the caller immediately, bypassing the servlet
> entirely ?
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to