background image

Encapsulating Reusable Content Using Tag Files

<< Communication between Tags | Tag File Location >>
<< Communication between Tags | Tag File Location >>

Encapsulating Reusable Content Using Tag Files

<%@ taglib tagdir=
"/WEB-INF/tags" prefix="h" %>
<%@ taglib uri=
"http://java.sun.com/jsp/jstl/core"
prefix=
"c" %>
<%@ taglib uri=
"http://java.sun.com/jsp/jstl/functions"
prefix=
"fn" %>
<html>
<head><title>Hello</title></head>
<body bgcolor=
"white">
<img src=
"duke.waving.gif">
<c:set var=
"greeting" value="Hello" />
<h2>${greeting}, my name is Duke. What
's yours?</h2>
<form method=
"get">
<input type=
"text" name="username" size="25">
<p></p>
<input type=
"submit" value="Submit">
<input type=
"reset" value="Reset">
</form>
<c:if test=
"${fn:length(param.username) > 0}" >
<h:response greeting="${greeting}"
name="${param.username}"/></c:if>
</body>
</html>
To deploy and run the hello3 application with NetBeans IDE, follow these steps:
1. In NetBeans IDE, select File
Open Project.
2. In the Open Project dialog, navigate to:
tut-install/javaeetutorial5/examples/web/
3. Select the hello3 folder.
4. Select the Open as Main Project check box.
5. Click Open Project Folder.
6. In the Projects tab, right-click the hello3 project, and select Deploy Project.
7. To run the application, open the bookstore URL http://localhost:8080/hello3.
To deploy and run the hello3 application with Ant, follow these steps:
1. In a terminal window, go to tut-install/javaeetutorial5/examples/web/hello3/.
2. Type ant. This target will spawn any necessary compilations, copy files to the
tut-install/javaeetutorial5/examples/web/hello3/build/ directory, and create a WAR
file.
3. Start the Application Server.
4. To deploy the example, type ant deploy.
5. To run the example, open your browser to http://localhost:8080/hello3.
Encapsulating Reusable Content Using Tag Files
The Java EE 5 Tutorial · September 2007
234