users@glassfish.java.net

Re: JSF2 and JSP questions

From: Roger Kitain <roger.kitain_at_oracle.com>
Date: Tue, 14 Jun 2011 15:00:31 -0400

Sounds like you want to do some templating.
Facelets ( a powerful templating view technology) is a first class
citizen in JSF 2. Why not use it?

On 6/14/11 1:48 PM, emiddio-frontier wrote:
>
> I want to include content from a servlet into my JSF2 page.
>
> My understanding is I can use JSP with JSF1.x and "include" content
> from another servlet into the JSF1.x page being rendered ?
>
> I believe I can do this with JSP1.x two ways:
> <jsp:include page="..." /> with the JSP Core tag library
> and
> <c:import uri="..."/> with the http://java.sun.com/jsp/jstl/core -
> JSTL tag library.
>
> I have been unable to discover a way to accomplish this with JSP2 ?
> --The above tag libraries seem to be unrecognized when added to the
> xmlns=... of my xhtml file with JSF2.
> --And the JSTL library that is recognized has fewer tags than the
> standard JSTL ?
>
> I have experimented with an EL expression in the JSF2 page calling a
> void method that essentially does the following :
>
> HttpServletRequest request = (HttpServletRequest)
> FacesContext.getCurrentInstance().getExternalContext().getRequest();
> HttpServletResponse response = (HttpServletResponse)
> FacesContext.getCurrentInstance().getExternalContext().getResponse();
> request.getRequestDispatcher("/servlet1").include(request, response);
> request.getRequestDispatcher("/jspInclude3.jsp").include(request,
> response);
>
> with apparent success -- but this seems perhaps the wrong thing to do?
> and wondering what is the "better/correct" way to accomplish my intent?
>
> I have also discovered I can use <ui:include src="http://..."/> to
> invoke a servlet -- but without the 'http://' it seems to look for a
> file with the name used in the 'src' arg rather than a servlet with
> said mapping --- and if the page is a jsp file it seems to not invoke
> the jsp servlet --just wants to include the raw text?.
>
>
> Thanks
>
> gary
>
>
>
>
>


-- 
roger.kitain_at_oracle.com
https://twitter.com/rogerk09
http://www.java.net/blogs/rogerk