0% found this document useful (0 votes)
8 views

Java 5 Assign

Uploaded by

dryoplayz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Java 5 Assign

Uploaded by

dryoplayz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

TYCOA061 Assignment 5

login.jsp
?
1<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
2<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
3
4<html>
5<head>
6<title>Login Page</title>
7</head>
8<body>
9 <f:view>
10 <h1>
11 <h:outputText value="Login Page" />
12 </h1>
13 <h:form id="LoginForm">
14 <h:outputText value="Enter Your Name:" />
15 <h:inputText value="#{loginBean.userName}" />
16 <h:commandButton action="welcome" value="OK" />
17 </h:form>
18 </f:view>
19</body>
20</html>

welcome.jsp
?
1<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
2<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
3<html>
4<head>
5<title>Welcome</title>
6</head>
7<body>
8<f:view>
9<h3>
10<h:outputText value="Welcome" />,
11<h:outputText value="#{loginBean.userName}" /> to javawebtutor.com!
12</h3>
13</f:view>
14</body>
15</html>
LoginBean.java
?
1package com.jwt.jsf.bean;
2
3public class LoginBean {
4 private String userName;
5
6 public String getUserName() {
7 return userName;
8 }
9
10 public void setUserName(String userName) {
11 this.userName = userName;
12 }
13
14}
faces-config.xml
?
1<?xml version="1.0" encoding="UTF-8"?>
2
3<faces-config
4 xmlns="http://java.sun.com/xml/ns/javaee"
5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesco
7 version="1.2">
8 <managed-bean>
9 <managed-bean-name>loginBean</managed-bean-name>
10 <managed-bean-class>com.jwt.jsf.bean.LoginBean</managed-bean-class>
11 <managed-bean-scope>request</managed-bean-scope>
12 </managed-bean>
13 <navigation-rule>
14 <display-name>login</display-name>
15 <from-view-id>/login.jsp</from-view-id>
16 <navigation-case>
17 <from-outcome>welcome</from-outcome>
18 <to-view-id>/welcome.jsp</to-view-id>
19 </navigation-case>
20 </navigation-rule>
21
22</faces-config>

web.xml
?
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
3
<web-app id="WebApp_ID">
4
<display-name>HelloWorldJSF</display-name>
5
<servlet>
6
<servlet-name>Faces Servlet</servlet-name>
7
<servlet-class>
8
javax.faces.webapp.FacesServlet</servlet-class>
9
<load-on-startup>1</load-on-startup>
10
</servlet>
11
<servlet-mapping>
12
<servlet-name>Faces Servlet</servlet-name>
13
<url-pattern>/faces/*</url-pattern>
14
</servlet-mapping>
15
<welcome-file-list>
16
<welcome-file>login.jsp</welcome-file>
17
18
</welcome-file-list>
19
</web-app>

You might also like