You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marc Logemann <sp...@logemann.org> on 2004/03/03 02:10:42 UTC

processForwardConfig / freeze() / IllegalStateException

Hi,

i developed my own RequestProcessor (by inheritance and overriding) for some custom
behavior. Actually this exactly:

   protected void processForwardConfig(HttpServletRequest request, HttpServletResponse response, ForwardConfig forward) throws IOException, ServletException {

        final String symbolJspSuffix = "_s";

        String userAgentHeader = request.getHeader("User-Agent");
        if(userAgentHeader.lastIndexOf("Windows CE") != -1){
            // normal JSP forward Path (for non PIE browsers)
            String path = forward.getPath();

            // append the suffix to the name of the JSP (index.jsp => index_s.jsp)
            String modifiedPath = path.substring(0,path.lastIndexOf('.'));
            modifiedPath += symbolJspSuffix+ path.substring(path.lastIndexOf('.'));

            // set modifiedPath in the ForwardConfig
            forward.setPath(modifiedPath);
        }
        super.processForwardConfig(request, response, forward);
    }

---

As you can see, i have two version of my JSPs and the alternate version of them
is used on Windows CE devices. With my first action (a struts forward action),
its running quite nice, but after going to the second, i get an IllegalStateException.

After reading some code, i discovered that the "configured" attribute is set
and that i cant make any changes to the forward.path anymore, but this breaks
my little nice routine. So when does the freeze() method gets called and
how to avoid that?

When are ActionForwards "configured" and not modifiable anymore?
I really like the hook in processFOrwardConfig and dont want to give it up.

Thanks for infos 

marc


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: processForwardConfig / freeze() / IllegalStateException

Posted by Hubert Rabago <ja...@yahoo.com>.
Instead of modifying an existing forward (not sure you shoulda been doing
that, anyway), you can try creating a new one.  Copy the properties of the
one you received, then pass that one on.

>         if(userAgentHeader.lastIndexOf("Windows CE") != -1){
>             // normal JSP forward Path (for non PIE browsers)
>             String path = forward.getPath();
> 
>             // append the suffix to the name of the JSP (index.jsp =>
> index_s.jsp)
>             String modifiedPath = path.substring(0,path.lastIndexOf('.'));
>             modifiedPath += symbolJspSuffix+
> path.substring(path.lastIndexOf('.'));
> 
>             // set modifiedPath in the ForwardConfig
>             //forward.setPath(modifiedPath);
              ForwardConfig temp = new ForwardConfig();
              temp.setPath(modifiedPath);
              // copy other properties
              forward = temp;
>         }
>         super.processForwardConfig(request, response, forward);


Hubert

--- Marc Logemann <sp...@logemann.org> wrote:
> Hi,
> 
> i developed my own RequestProcessor (by inheritance and overriding) for
> some custom
> behavior. Actually this exactly:
> 
>    protected void processForwardConfig(HttpServletRequest request,
> HttpServletResponse response, ForwardConfig forward) throws IOException,
> ServletException {
> 
>         final String symbolJspSuffix = "_s";
> 
>         String userAgentHeader = request.getHeader("User-Agent");
>         if(userAgentHeader.lastIndexOf("Windows CE") != -1){
>             // normal JSP forward Path (for non PIE browsers)
>             String path = forward.getPath();
> 
>             // append the suffix to the name of the JSP (index.jsp =>
> index_s.jsp)
>             String modifiedPath = path.substring(0,path.lastIndexOf('.'));
>             modifiedPath += symbolJspSuffix+
> path.substring(path.lastIndexOf('.'));
> 
>             // set modifiedPath in the ForwardConfig
>             forward.setPath(modifiedPath);
>         }
>         super.processForwardConfig(request, response, forward);
>     }
> 
> ---
> 
> As you can see, i have two version of my JSPs and the alternate version of
> them
> is used on Windows CE devices. With my first action (a struts forward
> action),
> its running quite nice, but after going to the second, i get an
> IllegalStateException.
> 
> After reading some code, i discovered that the "configured" attribute is
> set
> and that i cant make any changes to the forward.path anymore, but this
> breaks
> my little nice routine. So when does the freeze() method gets called and
> how to avoid that?
> 
> When are ActionForwards "configured" and not modifiable anymore?
> I really like the hook in processFOrwardConfig and dont want to give it up.
> 
> Thanks for infos 
> 
> marc
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you�re looking for faster
http://search.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org