All blog posts, code samples and downloads licensed under Apache License 2.0.
Close

Force redirect to XSP page name

Oliver Busse on 10/28/2013 01:54:40 CET, filed under XSP 

Imagine your database with a web launch option pointing to an XPage. In your browser you just type

http://yourHost/yourDB.nsf

If it is important to have the desired page name (e.g. index.xsp) visible in the URL then use the code below in the page's beforePageLoad event.

var url = facesContext.getExternalContext().getRequest().getRequestURI();
if(url.indexOf(".xsp")==-1){
	if(url.endsWith("/")){
		url = url.substr(0, url.length-1)
	}
	context.redirectToPage(url+view.getPageName())
}

Tagged with redirect