Filter problem

Hello,

I have a java web application, I want 2 filters in it:

- LogFilter: mapped to /*
- RestrictedFilter: mapped to /WEB-INF/ticketing/*

Only the first one is executed. Have included system.out.print in each filter, so I know only the first filter is executed.

Attached is web.xml

Does anyone have an idea how to fix this?
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>ticketing</display-name>
  <resource-ref>
    <description>MySQL DataSource</description>
    <res-ref-name>jdbc/ticketing</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <description></description>
    <display-name>ProcessTicket</display-name>
    <servlet-name>ProcessTicket</servlet-name>
    <servlet-class>servlets.ProcessTicket</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>ProcessTicket</servlet-name>
    <url-pattern>/ProcessTicketServlet</url-pattern>
  </servlet-mapping>
  <servlet>
    <description></description>
    <display-name>CreateUserServlet</display-name>
    <servlet-name>CreateUserServlet</servlet-name>
    <servlet-class>servlets.CreateUserServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>CreateUserServlet</servlet-name>
    <url-pattern>/CreateUserServlet</url-pattern>
  </servlet-mapping>
  <listener>
    <listener-class>listeners.MyListener</listener-class>
  </listener>
  <servlet>
    <description></description>
    <display-name>LoginServlet</display-name>
    <servlet-name>LoginServlet</servlet-name>
    <servlet-class>servlets.LoginServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>LoginServlet</servlet-name>
    <url-pattern>/LoginServlet</url-pattern>
  </servlet-mapping>
  <filter>
    <display-name>LogFilter</display-name>
    <filter-name>LogFilter</filter-name>
    <filter-class>filters.LogFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>LogFilter</filter-name>
    <url-pattern>/LogFilter</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>LogFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <filter>
    <display-name>RestrictedFilter</display-name>
    <filter-name>RestrictedFilter</filter-name>
    <filter-class>filters.RestrictedFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>RestrictedFilter</filter-name>
    <url-pattern>/RestrictedFilter</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>RestrictedFilter</filter-name>
    <url-pattern>/WEB-INF/ticketing/*</url-pattern>
  </filter-mapping>
</web-app>

Open in new window

LVL 5
wolfje_xpAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
>     /WEB-INF/ticketing/*

you can't add a filter to WEB-INF as its not publicly accessible
ie. you cannot request it so no pojnt adding a filter
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wolfje_xpAuthor Commented:
Ok, I understand that.
But I use a master page, when a user is logged in, the pages included in the master page are in /WEB-INF/ticketing/...
I want to prevent someone typing in his browser master.jsp?page=loggedin or something, unless there's a user on the context ...
How can I do that ?  Should I move the include pages out of WEB-INF ?
0
objectsCommented:
you would need to filter on /master.jsp
or check in your master that the include can be accessed

filters work on the request path, not the file path in your application
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

wolfje_xpAuthor Commented:
It works half: when a user logs in correct, he is forwarded from master.jsp to ticketing.jsp (same idea as master page), filter is on /ticketing.jsp.
When I access ticketing.jsp from brower without being logged in (via master.jsp), filter is invoked, but instead of forwarding me to forbidden.html I get an error: org.apache.jasper.JasperException: java.lang.IllegalStateException: getOutputStream() has already been called for this response
Any idea?
0
objectsCommented:
hard to say without seeing your code
0
wolfje_xpAuthor Commented:
Seems I cannot upload the code ...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.