You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Hanack, Leif" <le...@hypoport.de> on 2007/02/28 09:45:28 UTC

ServletExternalContextImpl.redirect did not encode URL, so URL-rewriting fail

Hello, 
 
I'm using Spring WebFlow (SWF) in combination with MyFaces/Trinidad. I have the problem that the FlowPhaseListener from SWF is calling a method that triggers ServletExternalContextImpl.redirect be to called.
 
ServletExternalContextImpl:
    public void redirect(String url) throws IOException
    {
        if (_servletResponse instanceof HttpServletResponse)
        {
            ((HttpServletResponse)_servletResponse).sendRedirect(url);
            FacesContext.getCurrentInstance().responseComplete();            
        }
        else
        {
            throw new IllegalArgumentException("Only HttpServletResponse supported");
        }
    }

The redirect method is calling a sendRedirect on the response but did not encode the url, so in case of URL-rewriting the jsessionid is not attached!
 
I know that this code-snipplet will solve my problem:
 
String encodedUrl = ((HttpServletResponse)_servletResponse).encodeURL(url);
((HttpServletResponse)_servletResponse).sendRedirect(encodedUrl);
 
Did not no if this is a bug. Hope it is, and my patch will be integrated:)
 
What do you think?!
 
Thanks in advance, Leif
 
 
Mit freundlichen Grüßen
 
Leif Hanack
Software Development
 
Hypoport AG
Klosterstraße 71
D-10179 Berlin
Tel.:  +49 (0)30 / 4 20 86 - 292
Fax.: +49 (0)30 / 4 20 86 - 199
 
E-Mail:   leif.hanack@hypoport.de <ma...@hypoport.de> 
Internet: www.hypoport.de <http://www.hypoport.de/> 
 
Vorstand: Prof. Dr. Thomas Kretschmar (Co-CEO),
Ronald Slabke (Co-CEO), Marco Kisperth

Aufsichtsrat: Dr. Ottheinz Jung-Senssfelder (Vors.),
Jochen Althoff (stellv. Vors.), Christian Schröder

Handelsregister: HRB 74559, Berlin-Charlottenburg
USt-IdNr.: DE207938067

 

Re: ServletExternalContextImpl.redirect did not encode URL, so URL-rewriting fail

Posted by Matthias Wessendorf <ma...@apache.org>.
I am not sure, if we should do that in general.

In JSF the ExternalContext already contains a
encodeResourceURL() method for that.



On 2/28/07, Martin Marinschek <ma...@gmail.com> wrote:
> Please open a jira-issue in our bug-tracker, and attach a patch there
> (line-numbers should be included!)
>
> regards,
>
> Martin
>
> On 2/28/07, Hanack, Leif <le...@hypoport.de> wrote:
> >
> >
> > Hello,
> >
> > I'm using Spring WebFlow (SWF) in combination with MyFaces/Trinidad. I have
> > the problem that the FlowPhaseListener from SWF is calling a method that
> > triggers ServletExternalContextImpl.redirect be to called.
> >
> > ServletExternalContextImpl:
> >     public void redirect(String url) throws IOException
> >     {
> >         if (_servletResponse instanceof HttpServletResponse)
> >         {
> >
> > ((HttpServletResponse)_servletResponse).sendRedirect(url);
> >             FacesContext.getCurrentInstance().responseComplete();
> >
> >         }
> >         else
> >         {
> >             throw new IllegalArgumentException("Only HttpServletResponse
> > supported");
> >         }
> >     }
> >
> > The redirect method is calling a sendRedirect on the response but did not
> > encode the url, so in case of URL-rewriting the jsessionid is not attached!
> >
> > I know that this code-snipplet will solve my problem:
> >
> >
> > String encodedUrl =
> > ((HttpServletResponse)_servletResponse).encodeURL(url);
> > ((HttpServletResponse)_servletResponse).sendRedirect(encodedUrl);
> >
> > Did not no if this is a bug. Hope it is, and my patch will be integrated:)
> >
> > What do you think?!
> >
> > Thanks in advance, Leif
> >
> >
> > Mit freundlichen Grüßen
> >
> > Leif Hanack
> > Software Development
> >
> > Hypoport AG
> > Klosterstraße 71
> > D-10179 Berlin
> > Tel.:  +49 (0)30 / 4 20 86 - 292
> > Fax.: +49 (0)30 / 4 20 86 - 199
> >
> > E-Mail:   leif.hanack@hypoport.de
> > Internet: www.hypoport.de
> >
> >
> >
> > Vorstand: Prof. Dr. Thomas Kretschmar (Co-CEO),
> > Ronald Slabke (Co-CEO), Marco Kisperth
> >
> > Aufsichtsrat: Dr. Ottheinz Jung-Senssfelder (Vors.),
> > Jochen Althoff (stellv. Vors.), Christian Schröder
> >
> > Handelsregister: HRB 74559, Berlin-Charlottenburg
> > USt-IdNr.: DE207938067
> >
>
>
> --
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>


-- 
Matthias Wessendorf
http://tinyurl.com/fmywh

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

Re: ServletExternalContextImpl.redirect did not encode URL, so URL-rewriting fail

Posted by Martin Marinschek <ma...@gmail.com>.
Please open a jira-issue in our bug-tracker, and attach a patch there
(line-numbers should be included!)

regards,

Martin

On 2/28/07, Hanack, Leif <le...@hypoport.de> wrote:
>
>
> Hello,
>
> I'm using Spring WebFlow (SWF) in combination with MyFaces/Trinidad. I have
> the problem that the FlowPhaseListener from SWF is calling a method that
> triggers ServletExternalContextImpl.redirect be to called.
>
> ServletExternalContextImpl:
>     public void redirect(String url) throws IOException
>     {
>         if (_servletResponse instanceof HttpServletResponse)
>         {
>
> ((HttpServletResponse)_servletResponse).sendRedirect(url);
>             FacesContext.getCurrentInstance().responseComplete();
>
>         }
>         else
>         {
>             throw new IllegalArgumentException("Only HttpServletResponse
> supported");
>         }
>     }
>
> The redirect method is calling a sendRedirect on the response but did not
> encode the url, so in case of URL-rewriting the jsessionid is not attached!
>
> I know that this code-snipplet will solve my problem:
>
>
> String encodedUrl =
> ((HttpServletResponse)_servletResponse).encodeURL(url);
> ((HttpServletResponse)_servletResponse).sendRedirect(encodedUrl);
>
> Did not no if this is a bug. Hope it is, and my patch will be integrated:)
>
> What do you think?!
>
> Thanks in advance, Leif
>
>
> Mit freundlichen Grüßen
>
> Leif Hanack
> Software Development
>
> Hypoport AG
> Klosterstraße 71
> D-10179 Berlin
> Tel.:  +49 (0)30 / 4 20 86 - 292
> Fax.: +49 (0)30 / 4 20 86 - 199
>
> E-Mail:   leif.hanack@hypoport.de
> Internet: www.hypoport.de
>
>
>
> Vorstand: Prof. Dr. Thomas Kretschmar (Co-CEO),
> Ronald Slabke (Co-CEO), Marco Kisperth
>
> Aufsichtsrat: Dr. Ottheinz Jung-Senssfelder (Vors.),
> Jochen Althoff (stellv. Vors.), Christian Schröder
>
> Handelsregister: HRB 74559, Berlin-Charlottenburg
> USt-IdNr.: DE207938067
>


-- 

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces