0

I am geting used to be Java programmer, and I've just taught servlets. But IDEA ctreates index.jsp, when I choose "Create Web Application". I've run into one article where found out from about JSF. It was described as a better and newest version of WebApp desiging. I've written a project where index.jsp are used (web->src->main->webapp) inside this path. It was created by IDEA. Now I wanna substitude JSP with XHTML. I've done it, assebled my project and deployed. But when I go to

localhost:8080/web/

I see nothing. When I use "index.JSP", I can see content of my JSP-page. Please, help me to correct my project. What should I do?

1 Answer 1

2

In order to make JSF working, you have some configuration to do:

  • Make sure you have a faces-config.xml at the same level as WEB-INF folder, containing this for JSF 2.0:
<?xml version='1.0' encoding='UTF-8'?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
        version="2.0">
</faces-config>
  • JSF uses a servlet provided by Java EE, javax.faces.webapp.FacesServlet. You must add some elements into your web.xml, to declare this servlet:
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>
</web-app>

Using this configuration, you must put your JSF at the same level as WEB-INF and give them the extension .xhtml. Of course you can set the pattern.

JSF is not only make to replace JSF files. This is a big framework which allow you to write only the business logic. You will need to learn more about JSF before using it. Take a look right here.

Sign up to request clarification or add additional context in comments.

6 Comments

hah)) I am just exactly looking throught this article. I've done what is written there, particularly what you've said, but it is still not working = (
I've even added dependecies iinto pom.xml. But nothing is going right = (
What happens if you go to localhost:8080/web/index.xhtml? If it works, make sure index.xhtml is defined as a welcome file into your web.xml
hah))) you're reading my actions) are you a spy? nothing is working = ( I've done it before read your response
This is a configuration of your application server. The display-name of web.xml is useless for that.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.