You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Dieter Schicker <di...@dilino.org> on 2008/09/27 00:28:30 UTC

put jsp files into WEB-XML

Hi,

I'm new to myfaces. My question is: Can I put all my jsp files (except
index.jsp) into a directory under WEB-INF? With spring webmvc I could
protect my jsp files that way for example with a
InternalResourceViewResolver. Is there a similar functionality in myfaces?

Thanks
Dieter

Re: put jsp files into WEB-XML

Posted by Dieter Schicker <di...@dilino.org>.
Thanks! That's exactly what I was looking for.

> One way in JSF to do it is to just to extend or have a custom view
> handler that prepends the path with "/WEB-INF". There are probably
> several ways to do it, although I have to admit I don't know why you
> would want to.
>   
Well, my "wise" spring book says that it's safer to put the jsp files
into WEB-INF so that they can only be called by a controller and not
directly ... Since I'm using acegi security I'm not sure myself why I
would want to ... ;-)

Cheers
Dieter


> The core Sun RI implementation of the ViewHandlerImpl just uses the
> view ID of the view to dispatch the request to the JSP file of that
> name:
>
>     private boolean executePageToBuildView(FacesContext context,
>                                         UIViewRoot viewToExecute)
> ...
>         ExternalContext extContext = context.getExternalContext();
> ...
>         String requestURI = viewToExecute.getViewId();
> ...
>         extContext.dispatch(requestURI);
>
>
> So changing the view ID is the easiest way that I know of. You can do
> this in JSF 1.2 by using a ViewHandlerWrapper instance and changing
> the view ID passed to the wrapped handler when createView is called.
>
> -Andrew
>
>
> On Fri, Sep 26, 2008 at 4:28 PM, Dieter Schicker <di...@dilino.org> wrote:
>   
>> Hi,
>>
>> I'm new to myfaces. My question is: Can I put all my jsp files (except
>> index.jsp) into a directory under WEB-INF? With spring webmvc I could
>> protect my jsp files that way for example with a
>> InternalResourceViewResolver. Is there a similar functionality in myfaces?
>>
>> Thanks
>> Dieter
>>
>>     


Re: put jsp files into WEB-XML

Posted by Andrew Robinson <an...@gmail.com>.
Faces is based on the Servlet spec, so there should be no reason you
cannot do this. It may require a filter or a servlet with usage of the
RequestDispatcher.

One way in JSF to do it is to just to extend or have a custom view
handler that prepends the path with "/WEB-INF". There are probably
several ways to do it, although I have to admit I don't know why you
would want to.

The core Sun RI implementation of the ViewHandlerImpl just uses the
view ID of the view to dispatch the request to the JSP file of that
name:

    private boolean executePageToBuildView(FacesContext context,
                                        UIViewRoot viewToExecute)
...
        ExternalContext extContext = context.getExternalContext();
...
        String requestURI = viewToExecute.getViewId();
...
        extContext.dispatch(requestURI);


So changing the view ID is the easiest way that I know of. You can do
this in JSF 1.2 by using a ViewHandlerWrapper instance and changing
the view ID passed to the wrapped handler when createView is called.

-Andrew


On Fri, Sep 26, 2008 at 4:28 PM, Dieter Schicker <di...@dilino.org> wrote:
> Hi,
>
> I'm new to myfaces. My question is: Can I put all my jsp files (except
> index.jsp) into a directory under WEB-INF? With spring webmvc I could
> protect my jsp files that way for example with a
> InternalResourceViewResolver. Is there a similar functionality in myfaces?
>
> Thanks
> Dieter
>