Question about "Cannot find FacesContext"

Dear Programmers

I have written a little application with JSF.

I have defined the web.xml that way:

<servlet>

<servlet-name>FacesServlet</servlet-name>

<display-name>FacesServlet</display-name>

<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

<load-on-startup>1</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>FacesServlet</servlet-name>

<url-pattern>/faces/*</url-pattern>

</servlet-mapping>

And executed the application using the url: http://localhost:9080/TestJSFBook/faces/listBooks.jsp

Until here everything is ok.

Now I want to remove the "/faces" from the url, therefore I have defined the servlet mapping as following:

<servlet-mapping>

<servlet-name>FacesServlet</servlet-name>

<url-pattern>/*</url-pattern>

</servlet-mapping>

But I get "javax.servlet.jsp.JspException: Cannot find FacesContext"

Why is happen? Why can't I map it that way?

[1142 byte] By [dudushra] at [2007-10-2 0:50:13]
# 1
No ideas,... someone....
dudushra at 2007-7-15 18:00:31 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Why do not you use *.faces in your URL Pattern?
lava123a at 2007-7-15 18:00:31 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
HiFirst thanks a lot for helping me again.Second you were right, the pattern *.faces works fine, but I still wonder why the patterns *.jsp or /* didn't work. Anyway it is not so important.Again thanks for helping me.
dudushra at 2007-7-15 18:00:31 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
check the FAQ in jsf home, you can find the answer:) http://java.sun.com/j2ee/javaserverfaces/reference/faqs/index.html#faces_servlet
@smile@a at 2007-7-15 18:00:31 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Thanks
dudushra at 2007-7-15 18:00:31 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

Hi,

Can anyone guide me on how to get servletConfig in a Managed Bean?

I have got HttpServletRequest in the Managed Bean by following code

==========================================

Object o = (Object)

FacesContext.getCurrentInstance().getExternalContext().getRequest();

System.out.println(o.getClass().toString() );

if (o instanceof HttpServletRequest)

{

System.out.println(" JSF Web Project :o is insatnce of HttpServletRequest");

HttpServletRequest httpServletRequestObject = (HttpServletRequest) o;

System.out.println(" PORT#=" +httpServletRequestObject.getServerPort()) ;

Enumeration e = httpServletRequestObject.getAttributeNames() ;

disPlayEnums(e, "ATTRIBUTES FROM HTTPSERVLETREQUEST");

}

But how to get a servlet Config ?

gdfgfdgdfa at 2007-7-15 18:00:31 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...