My goal is to find out how I can get application URL from my bean in
service layer.  According to Mike, I made my bean servletContextAware so
that I can get application URL by calling Url url =
servletContext.getResource("/index.jsp");  However, I don't get the
host, port information from url.getHost(), urlGetPort()....

Is there a way I can inject HttpServletRequest to my service bean?

In the BasePage, we can get HttpServletRequest by calling 

(HttpServletRequest)
getFacesContext().getExternalContext().getRequest();


public static  HttpServletRequest getRequest() {

        return (HttpServletRequest) FacesContext.getCurrentInstance()

                                                .getExternalContext()

                                                .getRequest();

}

If I put the above method into my own bean, or uses
FacesUtils.getRequest(), I got nullPointerException.

Why the "getRequest()" method in BasePage works but not in my service
bean?  Seems to me if I could inject the facesContext to my bean, then I
can get HttpServletRequest.  With Request object, I should be able to
get URL by calling request.getUri or Url.

 

Please advice. Thank you.

QD


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to