#眉標= Java #副標=JBuilder實務應用(24) #大標=開發JSF應用程式 #作者=文/Dr. JBuilder -----box----- 程式1 Faces Servlet javax.faces.webapp.FacesServlet 1 Faces Servlet *.faces -----end----- -----box----- 程式2 <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> -----end----- -----box----- #程式3 f:view> -----end----- -----box----- #程式4 1.<%@page contentType="text/html; charset=Big5"%> 2.<%@taglib uri="http://java.sun.com/jsf/core" prefix= "f"%> 3.<%@taglib uri="http://java.sun.com/jsf/html" prefix= "h"%> 4. 5. 6.會員登入網頁 7. 8. 9. 10. 11. 12. 13. 14. 17. 18. 19. 20. 23. 24. 25. 26. 29. 30. 31.
Member ID: 16.
Password: 22.
28.
32.
33.
34. 35. -----end----- -----box----- 程式5 1. package jsf; 2. 3. public class LoginBean { 4. private String memberid; 5. private String password; 6. public String doAction() { 7. if (memberid.equals("Duke") && 8. password.equals("DukePwd")) { 9. return "success"; 10. } else { 11. return "failed"; 12. } 13. } 14. public void setMemberid(String memberid) { 15. this.memberid = memberid; 16. } 17. public void setPassword(String password) { 18. this.password = password; 19. } 20. public String getMemberid() { 21. return memberid; 22. } 23. public String getPassword() { 24. return password; 25. } 26. } -----end----- -----box----- #程式6 1. <%@ page contentType="text/html; charset=Big5" %> 2. 3. 4. Login Success. 5. 6.

7. Welcome, ${sessionScope.loginBean.memberid} 8.

9. 10. -----end----- -----box----- 程式7 1. <%@ page contentType="text/html; charset=Big5" %> 2. 3. 4. Login Failed 5. 6.

Login Failed...

7. 8. -----end-----