Forums Register Login

JasperException ,JspException & Cannot find FacesContext

+Pie Number of slices to send: Send
HI Team,
I added all jsf,jstl,commons related jars to the referenced library then also I am getting FacesContext cannot Find Exception
My JSP is like

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<f:view>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<body>
<h:form>
<h:inputText value="#{viewItemsFB.catalogueNumber}"></h:inputText>
<h:commandButton action="#{viewItemsPB.getViewItems}">GET ITEMS</h:commandButton>
</h:form>
</body>
</f:view>

<f:view> is mandatory ,but when i add these tags
I am getting JasperException ,but in console i am getting Cannot find FacesContext
Browser::
org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 4

1: <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
2: <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
3: <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
4: <f:view>

Console::
javax.servlet.jsp.JspException: Cannot find FacesContext
+Pie Number of slices to send: Send
Think you are testing JSP directly using .jsp URL. JSF application must have FacesServet in web.xml and it should be mapped with *.jsf or *.xhtml.

After verifying this, replace your .jsp extention with .jsf and test.
for e.g., http://localhost:7001/demoapp/page/welcome.jsf
+Pie Number of slices to send: Send
As of JSF version 2, JSP files are no longer allowed as View Templates. You must use "xhtml" files.

Raw JSPs could never be used with JSF, however. JSF is not an add-on tag library for JSP. And, in fact, in later versions of JSF, the View Template doesn't even compile to executable code the way that traditional JSPs do.

If you attempt to access FacesContext from a raw JSP or servlet, it will fail. The FacesContext is constructed and destroyed by the FacesServlet for each and every HTTP request/response cycle. It is not a durable object. So if the FacesServlet was not involved in the request processing, there will be no FacesContext to use.
These are the worst of times and these are the best of times. And this is the best tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1586 times.
Similar Threads
JasperException
jsf panelGrid
how to get back bean value in javascript
JasperException with JSTL
JSF NewBie
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:35:22.