Reputation: 309
I'm developing an application which requires two interfaces - one for mobile phones browsers and another one for normal PC browsers. The second interface needs to present more information and have a few more functions. of course, both of them are in the same project and use the same beans, etc. It os just the presentation layer which changes. For the time being, I have just the interface for mobile phones. It is accessible when I choose the address: //ip-address:8080/App/ but not when I try to go directly to the page with that interface: //ip-address:8080/App/page.jsp. I got the following error:
org.apache.jasper.JasperException: An exception occurred processing JSP page /page.jsp at line 30
javax.faces.context.FacesContext context = javax.faces.context.FacesContext.getCurrentInstance(); 30:
context.getViewRoot().setLocale(newLocale); 31: %> 32: 33:Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.NullPointerException org.apache.jsp.page_jsp._jspService(page_jsp.java:91) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Of course I have the information in my web.xml that the welcome page is set to
<welcome-file-list>
<welcome-file>faces/page.jsp</welcome-file>
</welcome-file-list>
if I were to remove this part from the web.xml would I be able to reach that page or is the problem related to something else? In the end I would like to reach different interfaces by providing links like this:
//ip-address:8080/App/mobile_page.jsp //ip-address:8080/App/browser_page.jsp
Thanks for any input. Best Regards, sass.
Upvotes: 1
Views: 567
Reputation: 1109292
This exception is telling that the FacesContext#getCurrentInstance()
is returning null
. This means that the FacesContext
is not been created. The one who is responsible for that is the FacesServlet
. This in turn means that the FacesServlet
is not been invoked at all.
To invoke the FacesServlet
you need to ensure that the request URL matches the url-pattern
of the FacesServlet
as definied in the web.xml
.
You seem to have mapped the FacesServlet
on /faces/*
. So, you need to open the page by http://ip-address:8080/App/faces/page.jsp and thus not by http://ip-address:8080/App/page.jsp.
Upvotes: 2
Reputation: 75406
If you use JSF you should not go directly to the JSP pages but through the handler (faces/* or *.jsf)
Upvotes: 1