Problem with Filter and Struts


Web tier: servlets, JSP, Web frameworks: Problem with Filter and Struts

  1. Problem with Filter and Struts (3 messages)

    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("/")) {
          filterChain.doFilter(servletRequest, servletResponse);

     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"
           <form-property name="login" type="java.lang.String"/>
           <form-property name="passw" type="java.lang.String"/>

      <forward name="main_page" path="/main_page.jsp"/>

    Can anyone help me with this problem?
    Tks, Rafael Naufal.

    Threaded Messages (3)

  2. Problem with Filter and Struts[ Go to top ]


    One thing I would look at is the scope of your form. Currently it looks like you have it in the Request data in your form is only valid for 1 request. Try changing the scope to session...

  3. Problem with Filter and Struts[ Go to top ]

    assuming the java code is inside your filter,

    you have to call the rest of the filters to continue..


     chain.doFilter(req, res);

    instead of the return
  4. re Problem with Filter and Struts[ Go to top ]

    because you use the DynaValidatorForm,so the pathResource.endsWith("/") always retrun a "false"status. because the pathResource may content the "?login=**&passw=**"

    if (pathResource.endsWith("/")) {
          filterChain.doFilter(servletRequest, servletResponse);