Possible to include a JSP in  a component response ?

Hello,
I am writing an UI component that needs to include a JSP in its response and I am having some issues with the include:
In the encodeBegin() method of the component, I do the include like this:
HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse();
ServletContext servletContext = (ServletContext)context.getExternalContext().getContext();
RequestDispatcher disp = servletContext.getRequestDispatcher(uri);
disp.include(request, response);
The called page is included in the response, but at the beginning of the page, not inside the calling component response. I am guessing it is because context.getResponseWriter() returns a different writer than the one obtained from the HttpServletResponse used in the included page, and that the 2 responses (the JSF and the included page) are assembled only when the JSF rendering is over.
Has anyone been confronted to the same problem, and if so, have you been able to solve it ?
Thanks in advance for any help.

Hi,
I suppose you have the same kind of problem discussed here
http://forum.java.sun.com/thread.jsp?forum=427&thread=516289
When you use includes, you have to use subviews and verbatims tags.
The funny thing is, you'll probably encounter the verbatim tag bug, which was blocker for me, so I switched to MyFaces.
Frederic

Similar Messages

  • Include a JSP file located in a JAR

    how is it possible to include a jsp file which is located in a jar? perhaps someone has already a solution for this hoping
    what I already have found out is that jasper parser supports loading JSP files out of JARs, indeed. but when using a <%@import file="foo.jsp"%> directive, this special method is not called. is there some workaround? should I set some special property?
    thx

    Did you ever figure this one out?

  • JSP Tag -- Including a JSP fragment in a Java Tag file

    Hi all,
    I have a query regarding JSP Tag file authoring by extending the TagSupport class. I would like to know if it is possible to include a JSP file fragment inside a Java file somehow.
    Specifically, I have created a simple template tag, which adds a header and footer template to the resulting HTML page.
    <bc:template>
    Hello World!
    </bc:template>produces for example
    <html><body>
    Hello World!
    </body></html>Now I have two JSP fragment files (head.jspf and foot.jspf), and I want to do do something like
    public class HtmlTemplateTag extends TagSupport implements TryCatchFinally {
      public int doStartTag() {
        // somehow include head.jspf
        return EVAL_BODY_INCLUDE;
      public void doFinally() {
        // somehow include foot.jspf
    }Which means, I want to execute had.jspf and foot.jspf from the Java class file. I am not sure if it is even possible. If anyone can help me with this, it would be greatly appreciated.
    thanks
    nilesh

    Your intention is to put a header/footer on pages in your web application?
    There is another way to do it - specify prelude/coda jsp fragments in web.xml
    Something like the following:
    <jsp-config>
      <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <include-prelude>/WEB-INF/jspf/head.jspf</include-prelude>
        <include-coda>/WEB-INF/jspf/foot.jspf</include-coda>
      </jsp-property-group>
    <jsp-config>

  • Is it possible to include JSP routines in a BSP Application?

    Hi experts,
    I'm just wondering if it's possible to include routines of a JSP application into a BSP application. Both are quite similar. How it would be implemented?
    I have started programming BSPs this week, so i'm still confused about what things i should do.
    Lots of thanks!
    <b><u>Javier Rguez.</u></b>

    Welcome to SDN.
    Look at below link, same issue discussed:
    How to call JSP from BSP
    Raja T

  • How to include more jsp?

    Hi,
    I've header.jsp, footer.jsp, content.jsp (which is loaded dynamically) and a main.jsp. I would include all jsp into main.jsp.
    This is the header.jsp
    <div id="logo" align="top">
    <img src="http://www.company.com/images/logo-red.gif"/>
    <div class="user-info">Welcome, <h:outputText value="#{user.email}"/></div>
    </div>
    The footer.jsp is
    <div id="footer">
    <div id="footer-copyright">Copyright &copy; 2006 MyCompany, Inc.</div>
    </div>
    The content.jsp is
    <h:dataTable value="#{controller.renderedSteps}" var="vitem"
    rowClasses="stepdescription-text">
    <h:column>
    <h:outputText id="stepDescription" value="#{vitem.step.description}"/>
    </h:column>
    <h:column>
    <h:commandButton value="next step"
    action="#{controller.nextStep}"
    rendered="#{vitem.isRendered}"
    disabled="#{vitem.isDisabled}" />
    </h:column>
    </h:dataTable>
    The body of main.jsp is
    <body>
    <f:view>
    <h:panelGrid>
    <jsp:include page="header.jsp"/>
    <jsp:include page="content.jsp"/>
    <jsp:include page="footer.jsp"/>
    </h:panelGrid>
    </f:view>
    </body>
    The problem is that when I load the main.jsp seems that the <div> are ignored.
    I'm very new in JSF and JSP\HTML.
    Thanks

    Use f:subview and use f:verbatim.
    First, f:verbatim... This JSF tag allows you to write HTML verbatim to your page. Whenever you have an HTML tag in any included page from a JSF app, it must be wrapped in f:verbatim. It is also good practice to use f:verbatim in your main page too, though it is not absolutely required. Do not wrap JSF tags in f:verbatim, it will not work.
    A general rule of thumb is to attempt to use as little HTML as possible. The JSF tag set with CSS actually eliminates the need for a great deal of HTML. I suggest picking up a good book that explains each component in the JSF library. Such as Core JavaServer Faces by David Geary and Cay Horstmann. Some free chapters can be found here (Check out "Basic Standard Components): http://www.horstmann.com/corejsf/
    Seconly, use f:subview when including a page. Either inside the included JSP or around the include statement. Like so:
    <f:subview id="header">
        <jsp:include page="header.jsp"/>
    </f:subview>
    OR
    <f:subview id="header">
    <f:verbatim><div id="logo" align="top">
    <a href="http://www.mycompany.com/">
    <img src="http://www.company.com/images/logo-red.gif"/>
    </a>
    <div class="user-info">Welcome, </f:verbatim><h:outputText value="#{user.email}"/><f:verbatim></div>
    </div></f:verbatim>
    </f:subview>For more information, check out this related forum posting:
    http://forum.java.sun.com/thread.jspa?threadID=715984&start=10&tstart=0
    Hope this helps!
    CowKing

  • Using a real file path to include a JSP using RequestDispatcher

    Hi,
    I am trying to figure out how to use RequestDispatcher inside a servlet to include a jsp page using a real file path instead of a context path. So for example I would want to do something like...
    RequestDispatcher rd = this.getServletContext().getRequestDispatcher("c:/tomcat/conf/think.jsp");
    Is this possible? tomcat is complaining that the path does not start with a "/"
    From a higher level I am trying to setup a solution where all of my web applications can share a set of global jsp pages and other resources. I know the easiest solution would be to put everything into one web application but this does not make sense in my situation because I have differnet web applications for different companies on the same server. Any help would be greatly appreciated. - krebsnet

    First of all...
    My test environment is Tomcat 4.1.24 and it runs on port 80 as my webserver as well.
    I can place the .jsp (or .html) in the shared folder. Not in the lib or class folders but right in the shared folder. I can then call it from multiple contexts without using the context path. Just tested it a minute ago. For example I have test.jsp in the shared folder and loaded it from two separate contexts (one named /demo and one named /inetapps) by calling Load test. It loaded in both of them and neither contain a test.jsp file.

  • How can I include a JSP, Maximized, and retain look and feel(WSRP)

    I have created a page group and defined a root page with a certain look and feel. There are two portlets on the page. Once the user clicks on a submit button, the portlet performs some action and includes a jsp included in the EAR file. The portlet needs to maximize the UI to display the jsp correctly.
    Once control returns back to the screen, the look and feel is lost and uses Oracle's default style. I have two questions:
    1. From the portlet, how can I retain the look and feel of the page group when referencing "external" jsp (i.e JSPs in the deployed portal EAR file).
    2. How can I "redirect" the user to the home page in a standard way? If there is not a standard way, how do I use the Oracle specific utilities to do it?
    All of my JSPs are developed externally out of the scope of the Oracle Portal.
    Environment - Oracle Portal 10.1.4 on Release 2 using WSRP to contact Oracle Release 3, hosted EAR file (WSRP Producer).
    Thanks in advance.

    Hi José,
    I don't think that is possible. But you can import the css files that ep uses for its look and feel and try to give your web pages similar look and feel. The tables and other controls used in EP are totally different and are done through complex JavaScript coding instead of simple HTML tags. If you want exact lok and feel then i thin you must go for a Webdynpro based application rather then a J2EE application with JSPs.
    Regards,
    Guru.
    PS: Give points for helpful replies.

  • Class Cast Exception in JSP of the component

    Hi,
      I am trying to call a web service from the JSP of the component.I have written the java code as a scriplets in the JSP. The problem i am facing is Class Cast Exception. The code is as follows
    String strKey = "wsclients/proxies/sap.com/CCMSContentBroker/com.sap.ccmscontentbroker.CCMSContentProxy";
    java.lang.Object obj ;
    obj = context.lookup(strKey);
    str1 = obj.getClass().getName();
    ContentBroker objCB= null; 
    objCB = (ContentBroker)obj; // getting error here
    ContentBroker is an web service interface. The same code is working if i write it in the component but not in the scriplet of the JSP.
    Can't we do the type cast in the JSP ?
    Cant we call the web services in the JSP?
    How to eliminate this Class cast Exception in my code?
    Thanks and Regards,
    Saravanan

    Hi Harini,
             Thanks for your reply. I have checked all the import statements in the JSP.The problem is in the Type casting of object <b>obj</b> to ContentBroker variable <b>objCB</b>.
    Are u saying typr casting is not possible in JSP or organising imports in the JSP.
    These are my imports statements in the JSP
    <%@ page import = "java.util.ResourceBundle" %>
    <%@ page import = "com.sapportals.htmlb.*" %>
    <%@ page import = "com.intel.ccmt.ccmscontentbroker.* "%>
    <%@ page import = "com.intel.ccmt.ccmscontentbroker.types.* "%>
    <%@ page import = "com.sapportals.portal.prt.contentconversion.XSLConverter" %>
    <%@ page import = "com.sapportals.portal.prt.component.IPortalComponentRequest" %>
    <%@ page import="java.io.File" %>
    <%@ page import="javax.naming.Context" %>
    <%@ page import="javax.naming.InitialContext" %>
    <%@ page import="javax.naming.NamingException" %>
    <%@ page import="java.util.StringTokenizer"%>
    Can u help me on rectifying this class cast Exception ?
    Thanks and Regards,
    Saravanan

  • How can I include a jsp file in other jsp from different applications?

              Hi,
              I'd like know if it´s possible to include jsp or servlet from different applications.
              

              Thanks Deepak but I think you don´t understand me.
              I would like the include works like a normal include. I have a jsp in my application
              and , when the client requests this jsp, in the jsp should be added the result
              of the other jsp ejecution that belong to other application in the same domain.
              Is this possible?
              Thank you very much.
              Deepak Vohra <[email protected]> wrote:
              > A Jsp from a different application is included with a relative url to
              >th=
              >e Jsp.
              ><%@ include file=3D"relative url" %>
              >
              >A Jsp could be included with request parameter.
              > <jsp:include page=3D'<%=3D request.getParameter("incFile") %>' />
              >
              >javilla wrote:
              >
              >> Hi,
              >>
              >> I'd like know if it=B4s possible to include jsp or servlet from differe=
              >nt applications.
              >
              

  • Problem including a jsp in edit mode

    Hello
    Somehow i have a problem while including a jsp page while displaying the edit mode.
    If my doEdot just writes something like "Hello World" into the response it just works fine.
    But if i try to include a jsp resource the problems start to arise:
    1. The normal resource lookup request.getResource(IResource.JSP, bla) returns an unavailable resource. This seems the be because although a working instance of my portlet is used, the passed request  belongs to another context.
    2. Passing a precomputed resource seems to work, the page definitly gets called (-> it gets compiled and no errors show in stacktrace), but a sap dialog shows, saying that no properties exist, that can get configured cry
    I even stripped the jsp page to the single line "Hello", it gets compiled, but not shown!?
                                                                                    edit: After the dialog a new dialog is shown sayin:  The specified root item cannot be retrieved from the configuration. Correct the entry before trying again
    Even IF my confoguration is wrong (higly possible), why does it only show when using include but not while writing directly into the response stream?
    Solution:
    Portlet gets called via doEdit and thus is in edit mode. Since jsp pages extend AbstractPortalComponent the service method does not serve via the doContent method but tries to call doEdit on itself. Since jsp pages usually do not define doEdit, the default edit behavior gets applied.
    Set Default mode within the request type and the request node.
    Message was edited by: Mark Vollmann

    Thank you it worked .I really doesn't have much experience in the front end.
    Thank you once again.
    I ahve another problem , this is alomst the same , here i have a html anchor when user clicks on that link i wnat to display the result in the same window , but it is displaying in the new window , it does not have frames , so i can not say target .
    here is the code , please give me advice
    <table>
    <tr>
    <td><jsp:include page="top.jsp" /></td>
    </tr>
    <tr>
    <td align="left" valign="top" width="50%"><jsp:include page="paneltranscripts.jsp" /></td>
    <td width="50%"><center>
    <%
    if(transcripts.length == 0)
    out.println("<h2>No Transcripts Avialable</h2>");
    else
    { %>
    <% out.println("You are viewing at ");%> <b> <%= roomname%> </b> <% out.println("room transcripts"); %>
    <br>
    <% out.println("To <b>view</b> the transcripts click on the link"); %>
    <br>
    <% out.println("To <b>download</b> the transcripts right click on the link, open it in new window and save the page"); %>
    <br>
    <br>
    <%
         for(int i=0;i<=transcripts.length-1; i++)
              if(transcripts.equals(""))
                   continue;
              else
              %>
                   <a href="/DigiChat/DigiClasses/Resources/<%= sitename%>/Transcripts/<%= roomname%>/<%= realtranscripts[i%">"><%= transcripts[i] %></a>
                   <br>
                   <br>
              <%
    %>
    </td>
    </tr>
    </table>
    When user clicks on the transcripts[i] i want to display the result in the same window.
    Thank you</a>

  • Best practices to include client libraries used at component level

    How to include component level resources, while following the best practices.
    Ex:
    I am looking at the geometrixx media site in CQ 5.6. In the some of components, ex: 2-col-article-summary we have a client library defined under the component.
    /apps/geometrixx-media/components/2-col-article-summary
    -2-col-article-summary.jsp
    -clientlibs
      -css
      -css.txt
    if i look at the categories of the clientlib, it is defined as follows
    categories String[] apps.geometrixx-media, apps.geometrixx-media.2-col-article-summary
    The only place this client library is included is in the head.jsp of main page level component.
        <cq:includeClientLib categories="apps.geometrixx-media.all"/> - this in turn embeds the apps.geometrixx-media
    my questions are as follows
    1) Why do we have two categories for the clientlib, if ithe second category name( apps.geometrixx-media.2-col-article-summary) is not being used. Is there is some other usage for this i am missing.
    2) Also these set of css is always included no matter whether a specific component is added to the page or not.
    3)  I could use the following to include the client at the component level, but this will cause unnecessary <script> and <link> elements at the component level mark up.
       <cq:includeClientLib categories="apps.geometrixx-media.2-col-article-summary"/>
    Essentially  i am trying to understand, how to include a specific component level resources while following the best practices

    Hi,
    I dont have CQ5.6 setup so could not see referring example but by looking at description i can say
    Ans 1. The client library can be invoked directly through tag lib as <cq:includeClientLib categories="category name"/> but it can also be invoked when you add "dependencies" property to client library folder and in that case it resolve all the dependencies first. So to answer your quesiton by looking at client library folder configuration you can not say that specific category has not been used any where or not invoked.
    Ans 2. Invoking client library folder completely depends on your code where you are placing call for client library using <cq:includeClientLib> tag and dependencies configuration. So you have to dig it more to trace out all the calls (also default css/js loads)
    Ans 3. Correct. So accomplish that best way to manage client library at component level and give it a unique name which can not be invoked any where neither through <cq:includeClientLib> call nor through dependenies configuration. This way you can avoide overridding of same library files. (Better to manage proper hierarchy of library)
    Hope it gives you some idea .
    Thanks,
    Pawan

  • Can we include a JSP page in an already included JSP Page

    Hi guys,
    I have a doubt with JSP include tag. The problem is ..
    Can we include a JSP page in an already included JSP Page
    AS shown below
    I have one JSP page
    Index.jsp
    -in this I am including "include.jsp"
    -Again within the "include.jsp" I am including "include1.jsp"
    It is neither giving an error nor displaying the content which is there in the "include1.jsp" but it is displaying the content of "include.jsp"
    first of all let me know whether it is possible or no.. If so then why is it not coming and what is required to do this..
    fast...
    Thanks
    Sreenadha Reddy K

    Hi guys,
    I have a doubt with JSP include tag. The
    g. The problem is ..
    Can we include a JSP page in an already included JSP
    Page
    AS shown below
    I have one JSP page
    Index.jsp
    -in this I am including "include.jsp"
    -Again within the "include.jsp" I
    he "include.jsp" I am including "include1.jsp"
    It is neither giving an error nor displaying the
    content which is there in the "include1.jsp" but it is
    displaying the content of "include.jsp"
    first of all let me know whether it is possible or
    no.. If so then why is it not coming and what is
    required to do this..
    fast...
    Thanks
    Sreenadha Reddy KIt is possible , u just have to change all the files and save them all again, clear the temp dirs where all the jsp's as compiled. Now after all this try , it should work .

  • How is it possible to include in the procedure  part of HTML ?

    Hi,
    how is it possible to include in the procedure HTML tags?
    Such description give error message:
    <%public void statt()%{%>
    <option value="US">United States</option>
    <option value="AF">Afghanistan</option>
    <option value="AL">Albania</option>
    <%}%>
    This procedure is used to avoid many times to write the same HTML part.
    What is wrong?
    Best Regards,
    sergey

    I understance what you are trying to do, but you are doing it poorly... you could do something like that if you passed the JSPWriter as an argument to the method, then used ou.print("<option ..."); instead of just doing what you are doing...
    But there is probably a better way... Just make a real short html page, like this:
    <select name="country">
      <option value="US">United States</option>
      <option value="AF">Afghanistan</option>
      <option value="AL">Albania</option>
    </select>And name it like... countryList.htm.
    Then, in your JSP, do something like:
    <jsp:include page="countryList.html"/> wherever you want the list to go...

  • How to include a jsp page in another jsp jsp page

    hi,
    i m trying to include a jsp page name "header.jsp" into one jsp page name"selectattribute.jsp" i m using these commands in "selectattribute.jsp"
    <%@include file "header.jsp"%> bcz both these jsp page are C:\program files\tomcat 4.0\webapps\examples\jsp\Poject\
    but the problem is that , i m invoking this jsp page "selectattribute.jsp" from a servlet reportcontroller.java using REQUEST DISPATCHER.
    the servlet is in
    C:\Program files\tomcat 4.0\webapps\examples\WEB-INF\classes\Project\
    i want to know how to include some other jsp page in a jsp page and how to invoke applet from jsp page when that particular jsp page is being invoked by servlet.
    plz help
    manish

    use this for including in your selectattribute.jsp
    <jsp:include page="header.jsp" flush="true"/>
    I never tried calling an applet. I think you can write the code for calling the applet in a javabean method and call the method in the jsp

  • Generic service 'Analysis Services (TEST1)' could not be brought online (with error '1060') during an attempt to open the service. Possible causes include: the service is either not installed or the specified service name is invalid.

    Hi,
    We have a cluster with 2 nodes. Everything works fine in Node1. When I try to failover TEST1 database to Node-2 it fails with this message.
    Generic service 'Analysis Services (TEST1)' could not be brought online (with error '1060') during an attempt to open the service.  Possible causes include: the service is either not installed or the specified service name is invalid.
    Any help is much appreciated.
    Thanks

    Hello,
    The error message is pretty straight forward, it's saying either the service isn't installed or it's not installed as the same service on that node. Did you install analysis services on the second node (from the error it seems like it isn't)?
    Sean Gallardy | Blog |
    Twitter

Maybe you are looking for