Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JasperException ,JspException & Cannot find FacesContext

 
S.Reddisekhar Reddy
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18304
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic