I´m starting with Struts and i'm having a problem using at the same time a filter and Struts. My filter intercepts all the requests to see if the user is logged in. If not, the user is dispatched to the login page, otherwise the acess to the desired resource is granted. I have the follwing code in my filter:
// Not to filter the login
if(!GenericValidator.isBlankOrNull(pathResource)) {
if (pathResource.endsWith("/login.do")) {
filterChain.doFilter(servletRequest, servletResponse);
return;
}
}
So I want not to filter the user authentication with this code above. But after the the return statement gets executed the request doesn't reach my action, it seems that it's processed and every time I am faced with the index page again. The code of my action isn't executed. Here is my struts-config.xml for this:
<form-bean name="myForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="login" type="java.lang.String"/>
<form-property name="passw" type="java.lang.String"/>
</form-bean>
<action
attribute="myForm"
input="/index.jsp"
name="myForm"
path="/login"
scope="request"
type="br.com.rafael.myproject.action.LoginAction">
<forward name="main_page" path="/main_page.jsp"/>
</action>
Can anyone help me with this problem?
Tks, Rafael Naufal.
-
Problem with Filter and Struts (3 messages)
- Posted by: Rafael Naufal
- Posted on: October 09 2005 20:09 EDT
Threaded Messages (3)
- Problem with Filter and Struts by Michael Miller on October 10 2005 13:40 EDT
- Problem with Filter and Struts by Sarath Chandra on October 11 2005 13:59 EDT
- re Problem with Filter and Struts by liu zhengjun on October 18 2005 22:51 EDT
-
Problem with Filter and Struts[ Go to top ]
- Posted by: Michael Miller
- Posted on: October 10 2005 13:40 EDT
- in response to Rafael Naufal
Hi,
One thing I would look at is the scope of your form. Currently it looks like you have it in the Request scope...so data in your form is only valid for 1 request. Try changing the scope to session...
M -
Problem with Filter and Struts[ Go to top ]
- Posted by: Sarath Chandra
- Posted on: October 11 2005 13:59 EDT
- in response to Rafael Naufal
assuming the java code is inside your filter,
you have to call the rest of the filters to continue..
like..
chain.doFilter(req, res);
instead of the return -
re Problem with Filter and Struts[ Go to top ]
- Posted by: liu zhengjun
- Posted on: October 18 2005 22:51 EDT
- in response to Rafael Naufal
because you use the DynaValidatorForm,so the pathResource.endsWith("/login.do") always retrun a "false"status. because the pathResource may content the "?login=**&passw=**"
if (pathResource.endsWith("/login.do")) {
filterChain.doFilter(servletRequest, servletResponse);
return;
}