aspose file tools*
The moose likes JSF and the fly likes JasperException ,JspException & Cannot find FacesContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JasperException ,JspException & Cannot find FacesContext " Watch "JasperException ,JspException & Cannot find FacesContext " New topic
Author

JasperException ,JspException & Cannot find FacesContext

S.Reddisekhar Reddy
Greenhorn

Joined: Jan 05, 2012
Posts: 29
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
Balaji Manoharan Bm
Greenhorn

Joined: Sep 22, 2013
Posts: 13
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
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
 
subject: JasperException ,JspException & Cannot find FacesContext