I have this login.xhtml JSF page:
<?xml version="1.0"?>
<jsp:root version="2.0"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<jsp:directive.page contentType="text/html"/>
<f:view>
<h:inputText value="#{userBean.id}"/>
</f:view>
</jsp:root>
Output HTML contains properly rendered <input> tag, but <jsp:*> are left untouched. Seems that JSF just didn’t understand them. Why?
Your’re using JSF 2.0 and the file has a
*.xhtmlextension. You’re actually using Facelets as view technology, not JSP. Facelets is the successor of JSP. You cannot mix Facelets with JSP tags. Get rid of all<jsp:>tags, they are worthless and ain’t ever going to work in a Facelets page. The JSP tags are only parsed when you name the file*.jspwhich will be picked up by servletcontainer’s builtinJspServlet. But since you’re using JSF 2.0 with Facelets, you already have theFacesServletfor the job. Forget JSP 🙂Here’s how your XHTML file should look like:
Note that you’d like to put that input component in a
<h:form>, but I bet that it’ll be just a test example.Also note that
<!DOCTYPE html>is perfectly legit here. You don’t need the XHTML doctype. Facelets will take care about setting the righttext/htmlcontent type,UTF-8character encoding and so on.See also: