It's not a secret anymore!
The moose likes JSF and the fly likes <h:form> with servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "<h:form> with servlet " Watch "<h:form> with servlet " New topic

<h:form> with servlet

alexandre monassa

Joined: Oct 01, 2013
Posts: 2
I'd like to know if is possible to get the parameters from a jsf form (h:form) through servlets. For example :
<h:inputText id="name"/>
<h:commandButton action="submit">

I want to get through Servlets rather than managedbeans.

doGet(HttpservletResponse response, HttpservletRequest request) throws exception {

String name = request.getParameter("name");


Nothing appear in the getParameter results , only appears when I use HTML form and input .
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Welcome to the JavaRanch, Alexandre!

No, it is not possible. JSF tags are processed by the FacesServlet. In order for any other servlet to replace the FacesServlet, that servlet would also have to replicate the JSF internal functionality provided by the FacesServlet.

You can - and I not infrequently do - put a stock HTML FORM on a JSF page that posts to a stock servlet or JSP, but of course, it acts just like any other HTML form. Meaning no JSF-supplied validation, no auto-population of backing bean variables, no auto-initialization of form control values, and so forth.

JSF provides managed beans instead of servlets because most HTML forms processing follows certain basic rules. Instead of making you replicate those processes on a page-by-page basis, JSF provided a Model/View/Controller framework where the FacesServlet and tag functions supply the Controller functionality so that you can define the View in an abstract View Template Language and your UI Model objects can be implemented in POJO code rather than having to code specifically for a given environment (such as the web) or framework (such as Struts).

The whole point of JSF, in fact, is to minimize work and reduce maintenance costs without requiring complexity or arcane code.

An IDE is no substitute for an Intelligent Developer.
alexandre monassa

Joined: Oct 01, 2013
Posts: 2
Thanks @Tim Holloway, I 'm kind of gracefully. I did a html form and put some jsf fields like inputtext, and the servlet request var didn't get the jsf ones , it just get the html ones. So I had tried to do this until now , but After your answer I won´t try again. Thanks.
I agree. Here's the link:
subject: <h:form> with servlet
It's not a secret anymore!