![]() |
Restricting access to jsp pages in Filters
Hi ,
I am using a filter to prevent direct access to jsp pages (everything works fine). But I have 2 pages that should not be "filtered" when the url is given. Like the welcome.jsp page . When the user gives welcome.jsp page it should not be forwarded to the login.jsp page (I am redirecting all the other jsp pages to login.jsp page) . I dont want to hard code it using if () stmts in the filter. Please provide me the solution so tht when the user enters the welcome.jsp , he is directed to welcome.jsp page instead of login.jsp page. Is there any way to do it in the web.xml. thanks |
you could specify the pages u want to be ignored by the filter in the form of initialization parameters which can be specified in web.xml
|
how do I specify the initialization parameters in the web.xml
Hello Shyam ,
Thanks for the reply. How do I specify these jsp pages in the web.xml . Can u please provide me the sample code . Where do I need to initialize the parameters (is tht inside the filter declaration ??) . Please provide the solution |
Code:
<filter> |
Filter in web.xml (initialising the jsp pages)
Hi Shyam ,
I made the changes you suggested in the web.xml , but the filer still filters the welcome.jsp and redirects to the login.jsp page . Do I need to add any code anywhere other than the web.xml (I just added the <init-param> <param-name>allow-without-auth</param-name> <param-value>/welcome.jsp</param-value> </init-param> in the web.xml ) this is my web.xml -- <filter> <filter-name>filter</filter-name> <filter-class> RedirectFilter </filter-class> <init-param> <param-name>allow-without-auth</param-name> <param-value>/welcome.jsp</param-value> </init-param> </filter> <filter-mapping> <filter-name>filter</filter-name> <servlet-name>RedirectFilter</servlet-name> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <!-- <url-pattern>*.jsf</url-pattern> --> </filter-mapping> <filter-mapping> <filter-name>filter</filter-name> <url-pattern>*.jsf</url-pattern> </filter-mapping> ---- --- Please help me solve this prob thanks |
just adding the init-param isn't gonna magically do anything...you've to code in the Filter to take appropriate action based on the specified params
|
| All times are GMT +1. The time now is 07:27 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.