How to make redirect to page with another context?

View: New views
3 Messages — Rating Filter:   Alert me  

How to make redirect to page with another context?

by Anton Gavazuk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

actually, question is in the subject: How to make redirect from JSF
application to a page with another context, like www.google.com

Thanks,
Anton

Re: How to make redirect to page with another context?

by Richard Yee-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If you want to do it programmatically from an action,
You can try this method

/**
* Redirect to a new url
* @param url an external url
*/
void redirect(String url) throws IOException{
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalCtx = facesContext.getExternalContext();
externalCtx.redirect( url);
}

-Richard


On Sat, Oct 24, 2009 at 4:32 AM, Anton Gavazuk <antongavazuk@...> wrote:
> Hi all,
>
> actually, question is in the subject: How to make redirect from JSF
> application to a page with another context, like www.google.com
>
> Thanks,
> Anton
>

Re: How to make redirect to page with another context?

by Anton Gavazuk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Richard,
thanks

I knew about that method but I was trying to redirect incorrect URL like "
www.google.com".
to make redirect works URL must be in full form: "http://www.google.com".
I hope noone will make the same mistake :)


2009/10/24 Richard Yee <richard.k.yee@...>

> If you want to do it programmatically from an action,
> You can try this method
>
> /**
> * Redirect to a new url
> * @param url an external url
> */
> void redirect(String url) throws IOException{
> FacesContext facesContext = FacesContext.getCurrentInstance();
> ExternalContext externalCtx = facesContext.getExternalContext();
> externalCtx.redirect( url);
> }
>
> -Richard
>
>
> On Sat, Oct 24, 2009 at 4:32 AM, Anton Gavazuk <antongavazuk@...>
> wrote:
> > Hi all,
> >
> > actually, question is in the subject: How to make redirect from JSF
> > application to a page with another context, like www.google.com
> >
> > Thanks,
> > Anton
> >
>