Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

how to start JSF??  RSS feed

Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am new to JSF, so can anybosy tell me how to configure jsf in my web project??

thanks in advance
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try a test bean

Test bean

package demo;

public class Test {
public String cancel() {
System.out.println("cancel() called");
return "startPage";

public String save() {
System.out.println("save() called");
return "startPage";

private String field1;
private String field2;

public String getField1() {
field1 = readField1FromDatabase(); // read field1 from database
System.out.println("getField1() called; return " + field1);
return field1;
private String readField1FromDatabase() {
return "Ponnazhagan";

public void setField1(String field1) {
System.out.println("setField1() called with " + field1);
this.field1 = field1;
public String getField2() {
field2 = readField2FromDatabase(); // read field2 from database
System.out.println("getField2() called; return " + field2);
return field2;
private String readField2FromDatabase() {
return "Sudhakar";

public void setField2(String field2) {
System.out.println("setField2() called with " + field2);
this.field2 = field2;


<%@ taglib uri="" prefix="h" %>
<%@ taglib uri="" prefix="f" %>

<title>Test Page</title>
<font color="red"><h:messages/></font>

Bean Field 1: <h:inputText value="#{test.field1}"/><br>
Bean Field 2: <h utputText value="#{test.field2}"/><br>
<h:commandButton value="cancel" action="#{test.cancel}" immediate="true"/>
<h:commandButton value="save" action="#{}"/>


faces-config.xml - in WEB-INF







<!-- Faces Servlet -->
<servlet-name>Faces Servlet</servlet-name>
<load-on-startup> 1 </load-on-startup>

<!-- Faces Servlet Mapping -->
<servlet-name>Faces Servlet</servlet-name>

URL : http://localhost:8080/webapps/pages/test.jsf
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you recomend me to learn : Struts or Jsf ?
Thanks , victor
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!