First JSF tutorial with Eclipse Neon, Tomcat 9

  1. In eclipse, Window/Show View/Servers
  2. If you have a working Tomcat in Eclipse, go to step 6.
  3. Download and unzip Tomcat 9 anywhere on your computer.
  4. If this is a new Eclipse and no Tomcat is already in the Servers tab window, right click on that window, select New Server.  Select Tomcat vX.x Server which is the version Tomcat you downloaded and unzipped. Click Next
  5. Click Browse to fill in the directory where you downloaded Tomcat.  Click finish.
  6. In Eclipse, create a new Dynamic Web Project; here is one way: File / New / Project / Web / Dynamic Web Project.  Next.
  7. ProjectName: JsfTut.  Configuration:  Click Modify button. (On old versions of Eclipse, we just selected the Jsf2.2 config, no modify, no save).  Select Java Server Faces v2.2.  Click Save As.  Name it MyJsf2.2Config.  You’ll be using this config in future JSF projects.
  8. Hit Next until you get to the JSF Capabilities screen.
  9. Type: User Library.  Below it, right click (or click the download button beside it) and download library for JSF 2.2.  Also before clicking finish, highlight *.faces and click the Remove button to remove any mapping patterns that are there.  Click the Add button and add *.jsf     Now click finish.
  10. In Project Explorer, expand your new project.  Navigate to WebContent/WEB-INF, and right-click on web.xml.  Open With/Text Editor.
  11. Add the lines listed below into web.xml just before the web-app closing tag
  12. Now we’ll create a home page of type xhtml.  Right-click on the project name in Project Explorer: JsfTut.  New/Html File/index.xhtml.  Click finish.  Delete its contents and replace them with the contents in the second piece of code below
  13. It’s ready to run.  Eclipse can show the web page but it will take a minute.  Right click on the project name (JsfTut)/ Run As/Run on Server/ Select the Tomcat Version and proceed.  In Eclipse, the web page should say “Congrats this works”.  If it worked for you, show some luv, and leave a comment below. 🙂

    Congrats, this works!

 <context-param>
 <param-name>javax.faces.PROJECT_STAGE</param-name>
 <param-value>Development</param-value>
 </context-param>
 <welcome-file-list>
 <welcome-file>index.jsf</welcome-file>
 <welcome-file>welcome.jsf</welcome-file>
 <welcome-file>index.html</welcome-file>
 <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>

index.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>JsfTut</title>
</h:head>
<h:body>
<h1>Congrats, this works!</h1>

</h:body></html>
Advertisements

About SunKing2

Former web developer, guitar player, started Piano 2012 -yes still doing it! Recovery, sobriety, mental health advocate.
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to First JSF tutorial with Eclipse Neon, Tomcat 9

  1. Pingback: Second JSF Tutorial with Eclipse, Tomcat | Connected Web

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s