-
1. Re: How to get request object, for example the servletPath
basel Sep 7, 2006 10:18 AM (in response to juan_uy)Try not to use the Servlet API unless you have. Try something similar to this:
@In private FacesContext facesContext; private HttpServletRequest request; public void initComponent(){ request = (HttpServletRequest)facesContext.getExternalContext().getRequest(); }
-
2. Re: How to get request object, for example the servletPath
juan_uy Sep 7, 2006 11:08 AM (in response to juan_uy)Basel,
Thanks!! You saved me many nightmares!!. I 'll not try to use it for business logic, I will simple use to get a node from the database using the servlet path instead of putting a node's id variable in the url parameter :P.
juan. -
3. Re: How to get request object, for example the servletPath
ssilvert Sep 7, 2006 11:34 AM (in response to juan_uy)Actually, you should avoid casting to HttpServletRequest if at all possible because your application will break if/when you run it as a portlet.
ExternalContext has methods available for path information.
ExternalContext extCtx = facesContext.getExternalContext();
extCtx.getRequestContextPath();
extCtx.getRequestServletPath();
extCtx.getRequestPathInfo();
etc. -
4. Re: How to get request object, for example the servletPath
juan_uy Sep 7, 2006 3:33 PM (in response to juan_uy)Stan,
Cool!! This is just I wanted, with this solution I forgot the Servlet API,
Thanks!! :P
juan.