internet
internet

Reputation: 385

FacesContext redirect with Application context

I want to implement a redirect to a page in my application. My current problem is that I not got the application name.

The following code redirect to localhost:8080/index.hmtl:

FacesContext.getCurrentInstance().getExternalContext()
                .redirect("/index.html");

But I want to have: localhost:8080/myapp/index.html

How can I do this?

Upvotes: 1

Views: 3990

Answers (1)

David
David

Reputation: 153

requestcontextpath is what you need! it is in externalcontext

ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
context.redirect(context.getRequestContextPath()+"/index.xhtml");

Upvotes: 3

Related Questions