This is the bean which is called from .jsp page
import javax.faces.context.FacesContext; public class ServletTest { public void doThis(){ String url = "url of your servlet"; FacesContext context = FacesContext.getCurrentInstance(); try { context.getExternalContext().dispatch(url); }catch (Exception e) { e.printStackTrace(); } finally{ context.responseComplete(); } } }
This is the .jsp page
<f:view> <h:form id="myForm"> <h:commandButton value="Do" action="#{ServletTest.doThis}" /> </h:form> </f:view>