Reputation: 65
Please can somebody help me out,I need to verify the url action mapping of struts 1 on Filter level.If the provided url action mapping exist in Struts1 then it is ok otherwise show 404 error. This code show 404 page but i need to validate url before showing it:
p_hsResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
Upvotes: 1
Views: 1338
Reputation: 89189
Based on your comment, I don't think that its wise to validate the request path info to the struts action mapping.
What I will suggest is to map your Filter to the same <url-mapping>
your Struts ActionServlet
is mapped to.
Example:, should your ActionServlet
is mapped on to *.do
(suffix mapping), your filter should be mapped to the same.
<filter>
<filter-name>My filter</filter-name>
<filter-class>com.myApp.myFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>My filter</filter-name>
<url-pattern>*.do</url-pattern><!-- The same <url-pattern> to my Struts ActionServlet class
</filter-mapping>
That way, it will execute prior/after your struts ActionServlet call.
Upvotes: 1