I have this button in header that I include in many page:
<input type="button" value="My Button" onclick="window.location.href='mypage.xhtml'"
It use relative path and it works if the caller page is in the same directory.
How can I use absolute path or use commandButton tag ?
I tried with:
/mypage.xhtml
Don’t work (404 error)
Let EL print the context path dynamically. It’ll become relative to the domain root.
Or, better, just use JSF’s own
<h:button>component which generates the same HTML anyway wherein you don’t need to worry about the context path.If you need to pass any request parameters, you can use
<f:param>for that.Don’t use the
<h:commandButton>. It doesn’t send a normal GET request, but a POST request which you’d need to redirect and thus you effectively end up with two HTTP requests wherein all request parameters are lost in the second one.