exception « URL « JSP-Servlet Q&A

1. Liferay hook: filter url giving filterstart error and current url generates exception null    stackoverflow.com

I'm trying to make an autologinfilter in Eclipse using a liferay hook. Now I've added the:

to ...

2. Handle a non existing servlet exception    stackoverflow.com

When I type a non-existing servlet in a url an exception error

HTTP Status 404 - 
that's reasonable, but where should I handle the exception? at what scope??