This week's book giveaway is in the Agile forum.
We're giving away four copies of The Software Craftsman and have Sandro Mancuso on-line!
See this thread for details.
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 The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JasperException ,JspException & Cannot find FacesContext " Watch "JasperException ,JspException & Cannot find FacesContext " New topic

JasperException ,JspException & Cannot find FacesContext

S.Reddisekhar Reddy

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="" prefix="f" %>
<%@ taglib uri="" prefix="h" %>
<%@ taglib uri="" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<h:inputText value="#{viewItemsFB.catalogueNumber}"></h:inputText>
<h:commandButton action="#{viewItemsPB.getViewItems}">GET ITEMS</h:commandButton>

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

1: <%@ taglib uri="" prefix="f" %>
2: <%@ taglib uri="" prefix="h" %>
3: <%@ taglib uri="" prefix="c" %>
4: <f:view>

javax.servlet.jsp.JspException: Cannot find FacesContext
Balaji Manoharan Bm

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: 16541

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.
I agree. Here's the link:
subject: JasperException ,JspException & Cannot find FacesContext