|
Spring Framework |
|
<web-app> element. So the initial format of
this file will be like this:
<?xml version=”1.0"?>
<web-app>
..................................
..................................
..................................
</web-app>
If you want to create this file then write above
code in notepad and save it with name “web.xml” in the WEB-INF folder of your
application. After creating and placing this file
to the appropriate position, we have to add
child elements within web-app element. We
will write those elements will be described
later.
2. faces-config.xml: Now we come to the
second file “faces-config.xml” that will be in the
same place where web.xml is i.e. within WEBINF
folder. Here also you have to take care of
mentioning version of xml as we did in web.xml
file. All sub elements will be written within <faces-config> element. So initial format of this
file will be like this:
<?xml version=”1.0"?>
<faces-config>
.................................
.................................
.................................
</faces-config>
You can create this file also by your own or
copy from other JSF Application. If you want to
create this file then you can write the above
code in notepad and save it with the name “faces-config.xml” in WEB-INF folder of your application. After creating and placing this file
to the appropriate position, we have to add
some elements within faces-config element. How
we will write those elements will be described
later.
So now there will be two xml files web.xml and
faces-config.xml in WEB-INF directory. |
|
This JSF application contains:
1 Three JSP pages for viewing purpose
2 JavaBean to hold model data
3 Configuration files specifying managed
bean, navigation rules, controller servlet.
Now our first step is to create view part of the
application. For this we have created three JSP
files given below:
1. index.jsp
2. inputname.jsp
3. result.jsp
Creating JSP pages:
1-index.jsp:
The index page is stored in root directory “JSFHelloApplication”. The code for “index.jsp”
is:
<html>
<body>
<jsp:forward page=”/pages/
inputname.jsf” />
</body>
</html>
Description:
As you can see in code above, this page simply
forwards the user to the page “inputname.jsp”
through <jsp:forward page=”/pages/
inputname.jsf” /> line of code. Index page doesn’t display anything to the user so you
can leave creating this page but it has one
benefit that you can start application simply
mentioning the application name and not specifying any file name at the end of URL i.e.
we can simply write http://localhost:8080/
JSFHelloApplication in the URL and see output
of the application.
So the first page that appears to the user is “inputname.jsp” not “index.jsp”. The code for “inputname.jsp” is:
JSF Application
So the first page that appears to the user is “inputname.jsp” not “index.jsp”. The code for “inputname.jsp” is: |
|
Oct 2007 | Java Jazz Up | 56 |
|
|
Pages:
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53 ,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63 ,
64,
65 ,
66 ,
67 ,
68 ,
69 ,
70,
71,
72,
73,
74,
75,
76,
77,
78,
Download PDF |
|
|
|
|
|
|
|
|
|