On 4/1/07, paksegu <[EMAIL PROTECTED]> wrote:
First I was trying to convert a servlet code to pojo so i can call them from JSF as manage beans but i ran into the problem of ServletContext and getServletConfig methods and thats where I am stuck at.
When you are in a JSF request, you can get to the ServletContext instance like this: FacesContext fc = FacesContext.getCurrentInstance(); ServletContext sc = (ServletContext) fc.getExternalContext().getContext(); Note that you have to do a cast, because JSF is designed to work on either servlets or portlets. Therefore, you might want to change the second line above to: ExternalContext ec = fc.getExternalContext(); because ExternalContext defines quite a few of the methods on the ServletContext (and ServletConfig) interfaces, which you can call directly. Craig
