|
Lets start with our first application "Hello World". If you explore the application created in previous steps you will find one JSP file with the name welcomeJSF.jsp. Change the text "JavaServer Faces" to "Hello World" in the welcomeJSF.jsp file. So the code will be like as given below:-
<%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%> <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%-- This file is an entry point for JavaServer Faces application. --%>
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <f:view> <h1><h:outputText value="Hello World" /></h1> </f:view> </body> </html>
|
Note:- In order to use Java Server Faces Components in JSP pages we need have access of two tag library, the HTML component tag library and the core tag library using html and core tag lib. We will discuss each one with the features in coming sections. The code above has "f:view" as Core Tag which represents the root of view and all JSF component tags must be inside view tag and "h:outputText" is HTML Tag which represents the Label.
Output:-
The following output will gets printed on the screen.
Hello World |