Qns about jsp:include and jsp:forward

It is said that <jsp:include>'s flush is only fixed to "true". Which means the page cannot pass its full control to another page using <jsp:forward> tag.
Is there any ways to overcome this problem? Using both in the same jsp and allow it to passes full control.

Hmm.. I'm using the form action to call back the jsp itself to validate something, and the include to add in another jsp file together with the original jsp to produce some addon visual effects.
So saying if validate is true, forward to another jsp.
So the form action.. cannot be use I think.

Similar Messages

  • Jsp include and jsp param

    Hi All,
    I have the following:
    <jsp:include page="anotherPage.jsp">
            <jsp:param name="testing" value="sdfasdfsd"/>
    </jsp:include> And in anotherPage.jsp I have:
    <%@ taglib uri="/WEB-INF/tld/commons-log.tld" prefix="log" %>
    <log:dump scope="request"/>
    <log:dump scope="session"/>
    <log:dump scope="page"/>
    <log:dump scope="application"/>
    <h3>
    Test: <%= request.getParameter("testing") %>
    </h3>Not only does this output:
    Test: null
    but I don't see 'testing' anywhere in the dumps! What is going wrong?
    Have I badly misunderstood parameter sending? :-/
    Actually, my assumption was that the include code puts the "testing" variable
    into the request.. 1) where does jsp:param put the data items it
    passes through and 2) if the data item didn't previously exist as a
    request parameter, does it ignore it?
    Any assistance would be most appreciated!
    Rob
    :)

    Depends on the server version you are using. If you are using a JSP 2.0 server like Tomcat 5, then you should be able to do that, as long as you set up the container correctly (to use servlet 2.4 and JSP 2.0 specs rather than 2.3 and 1.2...)
    Is you are using a JSP 1.2 container (less then TC5) then you will not be able to use EL anyware except in JSTL tags. The fix is to use the JSTL tags to do the include:
    <c:import url="thepage.jsp">
      <c:param name="param1" value="${attr}"/>
    </c:import>

  • Difference between jsp:include and %@ include

    what is the difference between <jsp:include> and <%@ include %>? which has better performance? When to use which? suppose i have a menu that should be included in every page, which should I use?
    Thank you
    Cal

    <%-- some date this page was last updated with that particular version of JSP file --%>
    <% include file="relative URL" %>
    You use the include directive, as indicated, to include a file in the main JSP file at the time the file is translated into a servlet. This is done at translation time and therefore if the included JSP file changes, all the JSP files that use this included file will need tobe updated. If you use this include statement then i would suggest that you add a date descriptor of the last time it was modifed so that you can go back and tell if you have updated a particular JSP file or not.
    <jsp:include page="relative url" flush = "true" />
    When you use the JSP descriptor like this, you are getting the requested JSP file at REQUEST time and therefore you do not hae to worry about updating the calling JSP page.
    Hope this helps

  • What is the difference between jsp :include and server side include

    what is the difference between jsp :include and server side include(request dispatcher include method)????
    i understand that both request dispatcher include method and jsp:include take dynamic data,so when would one use request dispatcher include and when jsp:include.
    Is the usage interchangeable?i believe jsp include is used only for jsp/html but include directive can be used to include servlets ,jsp and html....correct me if i m wrong and
    do suggest if u hav ny other diff in this context...

    The difference really is: in what format do you want your inclusions? If your environment has many Java developers and only a few designers that focus mainly on, say, Flash, that might push you more towards the server-side include() directive. Or, if you have a large set of pages that receive dynamic content that is displayed in a consistent fashion (such as a workflow header area on a page).
    If, on the other hand, you have more web designers, there may be a greater desire to deal in markup rather than Java code. Java developers themselves might prefer to view markup (JSP) that more resembles the eventual output than something occuring in Java code.
    Finally, there are considerations of tiering. While it is totally possible to (and I have previously) implement 'view classes' that render markup or generate layout templates, JSP's offer, IMO, a subtle, psychological advantage. By forcing a developer to work in a different format, markup versus Java source, the separation on view from controller and model becomes a bit easier. It is still possible to make mistakes, but if a developer at some point notices, "Wait, I'm in a JSP, should I be importing a java.sql class?", then the choice to use JSP includes has paid off in spades.
    - Saish

  • Questions about Java Servlets and JSP

    Hi,
    I'm a confident Java Programmer (and really enjoy using this language) but am very new to Java servlets and Java Server Pages.
    I have previously worked with Perl on my web projects (simple 'league' style voting pages). I read in my 'Core Java' book that I should no longer use perl or even cgi.
    I need to know more about Java servlets and Java Server Pages so I can make the switch to a 'real' programming language.
    I have a few questions:
    How should I start to learn JS and JSP?
    How applicable will the java knowlegdge I have already be?
    Are JSP common on the world wide web?
    What tools do I need to start? (I currently develop in JBuilder and have Java 1.4.1 Standard Edition)
    Is it likey my web host (and others) will support JSP?
    Thank-you very much for helping a novice get started,
    Regards,
    Paul

    Hi, Steve ...has to be frustrating! But do not despair.
    Let's suppose the servlet it's named MyServlet on package org.servlets
    WEB-INF should look:
    WEB-INF
    classes
    org
    servlets
    MyServlet.class
    web.xml
    web.xml file should have this two declarations:
    <web-app>
      <servlet>
        <servlet-name>MyServlet</servlet-name>
        <servlet-class>org.servlets.MyServlet</servlet-class>
      </servlet>
      <!-- other servlets -->
      <servlet-mapping>
        <servlet-name>MyServlet</servlet-name>
        <url-pattern>/MyServlet</url-pattern>
      </servlet-mapping>
      <!-- other servlets mappings -->
    </web-app>Now, once the container starts (Tomcat?), you should be able to see that servlet in:
    http://localhost:8080/[my-context/]MyServletAnd what my-context is? The web application context. This string should be empty if your're deploying to the root context, otherwise should the context name. In Tomcat, deploying to root context defaults to using webapps/ROOT.
    Sorry for my English, but I felt the need to answer your request. I hope it helps despite my writing.

  • WSAD: Evaluating JSP includes in JSP Preview

    Hello. I am a newbie to WSAD 5.0 and am trying to figure out how to get it to Evaluate JSP includes when I select to preview the JSP. Right now it does not evaluate the include and just leaves that tag in the generated HTML code.
    Thanks,
    ->Dave

    The preview mode doesn't evaluate the includes as it's not running the full jsp engine.
    To get what you want, right click on your jsp in the navigator view and select "Run on server".
    That will open a browser window and show your jsp in all it's magnificence.
    Regards,

  • About java beans and jsps

    hi,
    can anybody tell me is it good use only jsp for presentation and business logic.
    in terms of perfomence wise is it good practice.
    regards,
    sam

    I think you had better to write in a beans.otherwise,the work of maintenance will be difficult.

  • Jsp taglibs and jsp commands...

    Another question about taglibs...
    If I want to use the body in a tag together with a class which is used in the tag code.
    For example I want to do the following:
    <foo:listStudents>
    <%= student.fname %> <%= student.lname %> <%= student.id %>
    </foo:listStudents>
    Do I have to use the TagExtraInfo or? The class Student (student) is ofcourse declared and used in the tag.
    Regards Per Jonsson

    I am also on the lookout for this. i have posted many times but no one has answered my question till now. if you get to know the answer do inform me at
    [email protected]
    Regards
    Ramesh Kesavanarayanan

  • Valiable file name in JSP include

    Hi,
    I am trying to include a html file in a JSP page. The filename comes from the properties file and hence is a variable. The JSP file that has this include does not cache the JSP page plus it "refreshes" (reloads) ever 30 seconds.
    When I include the HTML file using jsp:include I am not getting the HTML file on alternate browser refreshes. Wierd?
    I then hard coded the filename and included the html file using <% @ include... and it works just fine.
    But I cannot have a variable name in <%@ include.
    Please comment on this wierd behaviour of jsp:include and gimme a solution.
    Thank you all in advance,
    Ravi Mittal

    Sorry this isn't a solution, because I have the very same problem and was just getting ready to post a question when I saw your post. I have also tried using:
    <jsp:include page="<%= myFilename %>" flush="true" />
    as well as
    <%@ include file="<%= myFilename %>" %>
    Neither of these work. This kind of approach seems to work just fine using <jsp:forward....>, but there's something funny about trying to include a file dynamically.
    I would also appreciate a solution. Good luck.
    - Joe

  • Try again: jsp:include fails with NPE in ValueBindingImpl

    JSF 1.1, RichFaces 3.1.3, WebLogic 9.2.2.
    I asked about this a couple of weeks ago, but I didn't get any useful responses.
    I have a simple "toy" application using a tabpanel that works fine right now. There is one tab that I will want to repeat several times, with only variations in the data in the fields (and the tab title). So, I copied the current template of that tab into an include file and I'm trying to include it with "jsp:include" from the original page, with a parameter. I've read all the suggestions about how to get jsp:include working with JSF, but it still doesn't work.
    When I display the page, I just get this:
    java.lang.NullPointerException
         at com.sun.faces.el.ValueBindingImpl.(ValueBindingImpl.java:98)
         at com.sun.faces.application.ApplicationImpl.createValueBinding(ApplicationImpl.java:292)
         at javax.faces.webapp.UIComponentTag.setProperties(UIComponentTag.java:890)
         at org.ajax4jsf.webapp.taglib.UIComponentTagBase.setProperties(UIComponentTagBase.java:80)
         at org.ajax4jsf.webapp.taglib.HtmlComponentTagBase.setProperties(HtmlComponentTagBase.java:78)
         at org.richfaces.taglib.TabTag.setProperties(TabTag.java:568)
         at javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:1017)
         at javax.faces.webapp.UIComponentTag.createChild(UIComponentTag.java:1036)
         at javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:749)
         at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:429)
         at jsp_servlet.__main._jsp__tag42(__main.java:1603)
    ...more...The JSP code for the tab looks like this:
    <rich:tab id="property0"
                name="#{ratingRequest.propertyList[0].propertyID}"
                label="Property: #{ratingRequest.propertyList[0].propertyID}"
                rendered="#{ratingRequest.propertyList[0].used}">
         <f:subview id="propertysubview0">
              <jsp:include page="/faces/propertyTab.jsp">
                   <jsp:param name="propertyIndex" value="0" />
              </jsp:include>
         </f:subview>
    </rich:tab>The file this tries to include is this:
    <%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
    <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <f:subview id="includedPropertyPage">
         <h:panelGrid id="propertyPanelGrid" columns="3">
              <h:outputText id="propertyIDOut" value="Property ID"/>
              <h:inputText id="propertyIDIn"
                              value="#{ratingRequest.propertyList[0].propertyID}">
                   <a4j:support id="propertyIDInSupport" event="onchange" reRender="propertyTable"/>
              </h:inputText>
              <rich:message for="propertyIDIn" showDetail="true"/>
              <h:outputText id="valueOut" value="Value"/>
              <h:inputText id="valueIn"
                              value="#{ratingRequest.propertyList[0].value}">
                   <a4j:support id="valueInSupport" event="onchange" reRender="propertyTable"/>
              </h:inputText>
              <rich:message for="valueIn" showDetail="true"/>
         </h:panelGrid>
    </f:subview>For more background, here's the code in the tab before I changed it to use jsp:include, and remember that this works:
    <rich:tab id="property0"
                name="#{ratingRequest.propertyList[0].propertyID}"
                label="Property: #{ratingRequest.propertyList[0].propertyID}"
                rendered="#{ratingRequest.propertyList[0].used}">
         <h:panelGrid id="property0PanelGrid" columns="3">
              <h:outputText id="propertyIDOut" value="Property ID"/>
              <h:inputText id="propertyIDIn" value="#{ratingRequest.propertyList[0].propertyID}">
                   <a4j:support id="propertyIDInSupport" event="onchange" reRender="propertyTable"/>
              </h:inputText>
              <rich:message for="propertyIDIn" showDetail="true"/>
              <h:outputText id="valueOut" value="Value"/>
              <h:inputText id="valueIn" value="#{ratingRequest.propertyList[0].value}">
                   <a4j:support id="valueInSupport" event="onchange" reRender="propertyTable"/>
              </h:inputText>
              <rich:message for="valueIn" showDetail="true"/>
         </h:panelGrid>
    </rich:tab>I don't have the source for the JSF implementation, but when I disassemble the class with the NPE, I see that the exception occurs in the ValueBindingImpl constructor that takes a Application object, and the NPE might occur because either the FacesContext or ExpressionInfoInstancePool is null (I think the former is the most likely, but I don't know why).

    Done. The results are ironically very similar to what happened with the BEA implementation, but I have a feeling this is something else, because it's failing not on the included page, but on a value binding on the main page. Perhaps I'm missing some property settings in my web.xml while using the RI.
    The entire stack trace is pretty large. I would have only included the excerpt from the root cause, but the JSF RI stack trace seems to have some interesting info up to that point. You'll see from the code at the top of the stack that either the FacesContext or the Application is null.
    org.apache.jasper.JasperException: Exception in JSP: /index.jsp:2
    1: <% session.invalidate(); %>
    2: <jsp:forward page="/faces/main.jsp"/>
    Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause
    org.apache.jasper.JasperException: Exception in JSP: /main.jsp:104
    101:                <rich:tab id="ratings" name="ratings" label="Ratings">
    102:                     <h:panelGrid id="ratingsPanelGrid" columns="3">
    103:                          <h:outputText id="field3Out" value="Field3"/>
    104:                          <h:inputText id="field3In" value="#{ratingRequest.field3}"/>
    105:                          <rich:message for="field3In" showDetail="true" passedLabel=" "/>
    106:                          <a4j:commandButton id="processRequest" value="Submit Request"
    107:                                             action="#{ratingRequest.processRequest}"
    Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
         org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
         org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
         org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
         org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
         org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:686)
         org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:656)
         org.apache.jsp.index_jsp._jspService(index_jsp.java:45)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause
    javax.servlet.ServletException: javax.servlet.jsp.JspException: null
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:837)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
         org.apache.jsp.main_jsp._jspService(main_jsp.java:134)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
         org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
         org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
         org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
         org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
         org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:686)
         org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:656)
         org.apache.jsp.index_jsp._jspService(index_jsp.java:45)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause
    java.lang.NullPointerException
         com.sun.faces.util.Util.getValueBinding(Util.java:987)
         com.sun.faces.taglib.html_basic.InputTextTag.setProperties(InputTextTag.java:265)
         javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:1027)
         javax.faces.webapp.UIComponentTag.createChild(UIComponentTag.java:1046)
         javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:761)
         javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:451)
         com.sun.faces.taglib.html_basic.InputTextTag.doStartTag(InputTextTag.java:506)
         org.apache.jsp.main_jsp._jspx_meth_h_005finputText_005f3(main_jsp.java:1375)
         org.apache.jsp.main_jsp._jspx_meth_h_005fpanelGrid_005f3(main_jsp.java:1309)
         org.apache.jsp.main_jsp._jspx_meth_rich_005ftab_005f3(main_jsp.java:1278)
         org.apache.jsp.main_jsp._jspx_meth_rich_005ftabPanel_005f0(main_jsp.java:950)
         org.apache.jsp.main_jsp._jspx_meth_a4j_005fform_005f0(main_jsp.java:208)
         org.apache.jsp.main_jsp._jspx_meth_f_005fview_005f0(main_jsp.java:162)
         org.apache.jsp.main_jsp._jspService(main_jsp.java:124)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
         org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
         org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
         org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
         org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
         org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:686)
         org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:656)
         org.apache.jsp.index_jsp._jspService(index_jsp.java:45)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

  • In portlet context include a jsp from the desktop context

    Hi,
    I developed a portlet, and in my jsp file I want to include a jsp file which is in my portal desktop (the file is in /etc/opt/SUNWps/desktop/..).
    So I want to do something like:
    <c:import url="file:///etc/opt/SUNWps/desktop/mydesktop/ PortletHeader.jsp" /> Of course this doesn't work because the jsp expressions are not executed, instead the jsp tags are just displayed in the browser.
    but for including a jsp with <@include file> or <c:import> or <jsp:include>, the jsp must run in its context. So actually we should do something like <c:import url="some_path" context="some_context" >.
    Now, I don't know what some_context is. To what context the portal desktop runs so the jsp file can be 'executed'?
    Hope someone can give me some more information about this.
    Greets,
    Tim

    <quote>some_context <quote>
    ..will be the pageContext
    which is the implicit object for a JSP.
    or
    use config object to get this context and then use
    <jsp:include> or <@include file>
    rgds
    http://lokeshpant.blogspot.com

  • Nested jsp:include includes wrong file

    Hi,
    I've encountered a somewhat strange problem that's upsetting me for more than 3 hours by now. I've searched on the Web, Usenet, Tomcat Bugzilla, and the java.sun.com forums, but still didn't find a solution.
    Let me explain my current JSP/servlet flow:
    A servlet retrieves an article from a database, puts the article data into a bean, sets that bean as request attribute and includes a JSP to display the content of this bean (your basic MVC pattern). This works fine.
    The page being included by the "retrieve" servlet is actually a layout page (index.jsp) including the JSP (article.jsp) which displays the bean data, so the servlet actually includes "index.jsp?c=article.jsp" (with the bean as request attribute).
    In that index.jsp, there's a jsp:include that should include the output from another MVC-style servlet/JSP-block: Servlet "poll" creates a PollBean from a database, puts that as attribute into the request and includes "polls/show.jsp".
    Here's a simplified representation of my page layout:
    +---------+---+       The outer box is the "index.jsp", which
    |         |   |      
    |         |   |       a) includes the servlet "retrieve"
    |    1    | 2 |          which in turn includes "article.jsp"
    |         |   |          at position 1 and
    |         |   |
    |         |   |       b) includes the servlet "poll"
    |         |   |          which in turn _should_ include "polls/show.jsp"
    |         |   |          at position 2
    +---------+---+Well now, my problem is: Somehow Tomcat manages it to include the "article.jsp" TWICE at position 1 AND 2, although the jsp:include at positon 2 reads (that's hardcoded):
    <jsp:include page="/poll?action=latest&limit=1" />
    And in the PollServlet (as you guess, mapped to "/poll") the file to be included is hardcoded to "polls/show.jsp".
    If there wouldn't be anything included at position 2, that would pretty clearly be an error with wrong relative paths used in the jsp:include at position 2. But what really scares me is that the "article.jsp" get's included at position 2 although some debugging statements show that the PollBean is actually in the request after the jsp:include at position 2 has been executed.
    I just don't get it why "article.jsp" is included twice, and although the poll servlet is called, the "polls/show.jsp" doesn't show up anywhere.
    I've tried to flush the "out"-JSPWriter of "index.jsp" at several different key locations in the code, even flushed() in the PollServlet after including "polls/show.jsp" but that didn't help.
    If you need some proof of this weird behavior, ask in this thread and I'll post the link the website where that happens.
    Thanks in advance,
    phil

    Try deleting all the compiled JSPs (usually in a
    directory called "work") then requesting the pageThat's what I did, too. I've gone through the whole make-Tomcat-start-all-over procedure:
    - reloaded via webapp manager: nope
    - stopped/started via webapp manager: nope
    - clear /work/ directory and restarted Tomcat: nope
    Didn't help anything.
    Have you debugged your PollServlet to see if it's
    returning/including the right (hard-coded) page?Mmh.. What should I debug there? There's not much to debug, if stuff is hard-coded like ...
    I just found the error in my code! duh I was just looking in Eclipse for a piece of code to post here when I saw my mistake:
    The CMS I'm currently adding the poll feature to is more flexible than I thought (and that although I wrote it myself!):
    The article-retrieve servlet is called by this URL:
    /retrieve?nextPage=article.jsp&id=12345And my poll servlet is called by
    /poll?action=latest&limit=1Normally this would include the "polls/show.jsp" from the PollServlet because the code in PollServlet reads:
    // Use nextPage from request or show by default
    nextPage = request.getParameter("nextPage");
    if(nextPage == null) nextPage = "polls/show.jsp";But when the PollServlet got called from the "index.jsp?c=retrive&nextPage=article.jsp&id=123" page, there actually was a "nextPage" param and it's value was "article.jsp". And because there was still an ArticleBean in the request (from the ArticleRetrieveServlet), this "article.jsp" included by the PollServlet displayed the article a second time.
    I fixed it by including my PollServlet's output with the "nextPage" parameter explicitly set:
    /poll?action=latest&limit=1&nextPage=polls/show.jsp
    The other way to test is to change your hard-coded
    page to some arbitrary HTML page so you know that at
    least it IS being included.That's something I didn't think about :)
    The other thing to test is to request this page
    (action) directly. So type
    /poll?action=latest&limit=1 into the browser and see
    what you get.Already did that, no problems.
    Sorry I can't be of more help... but I would bet the
    farm that it's not a problem with Tomcat.You're right. I'd really be shocked to have me find 2 bugs in Tomcat within the last to weeks (although the bug was already fixed in a newer version of Tomcat)
    Also... You may want to consider using Struts for your
    MVC if you can.Lots of people keep telling me that, but I'll want to do a general cleanup of the code first - maybe then I'll convert to Struts. After all I'm a freelancer and currently don't have time to learn Struts.
    Thanks for your help,
    phil

  • Debugging JSP includes

    We are having a debate on what type of jsp includes to use.
    One option is the static include:
    <%@ include file="testinclude.jsp" %>
    The other the dynamic include
    <jsp:include page="testinclude.jsp" flush="true" />
    A major stumbling block to using the former is that we can not seem to debug using it - a breakpoint set at that line appears to be ignored, and any breakpoints within the include itself also appear to be ignored. Why is that?
    Also, are there opinions on the pros and cons between these two methods?
    Thanks,
    Amy Schmieder
    Rentals.com

    Hi Amy,
    The difference between the two tags is that <%@ include> (the "include directive") is processed at compile time, and <jsp:include> (the "JSP include tag") is processed at runtime.
    A JSP is compiled into a Java servlet. When the compiler sees the include directive, it finds the relevant code, compiles it, and drops it straight in. A breakpoint on the directive is never reached because the directive doesn't exist in the compiled version at all (it's been replaced with the included code), and breakpoints in the included code are forgotten when the code is inserted (since they're not stored in the code itself).
    The jsp include tag, on the other hand, functions sort of like a method call to the included code. It's invoked at runtime.
    Advantages and disadvantages:
    On repeat hits, the include directive is faster, since it only needs to be processed once, at compile time.
    However, for just this reason, it's more limited. The jsp include tag can be dynamic--you can programmatically figure out, within your JSP, what you want to include (or, say, what parameters you want to pass the included page). An include directive won't let you do that--information about what exactly will be included must be present at compile time.
    So, for example,
    <jsp:include page="<%= includePage %>" flush ="ture"/>
    is perfectly legal, but
    <%@ include file="<%= includePage %>" %>
    isn't.
    Hope this helps,
    Avrom
    null

  • JSP include problem

    I am facing problems with the JSP include functionality in my project.
    What I want to do is to include jsp files on the fly i.e depending on the business need I should be able to swap in and out jsps from the main jsp.
    I plan to do this by feeding the file names in a request attribute and then including the files in the order given.
    But on using the jsp:include there is no output generated by the included jsp.
    There is no error either in the log or in the page directly.
    Please help me in finding out what exactly is the issue here.
    the files are index.jsp --> rightRailIncludeFiles.jsp --> dynamically loaded jsps (These may themselves contain other included files)
    index.jsp
    <div id="right" class="testRight">
        <%@ include file="rightRailIncludeFiles.jsp" %>
    </div>
    rightRailIncludeFiles.jsp
    <%
        out.println("<h1>Dyna Include</h1>");
        String fileNames = (String)request.getAttribute("jspFiles");
        String[] fileList = fileNames.split(",");
        out.println("<!-- Files : " + fileNames + " -->");
    %>
    <%
    for(int i=0;i<fileList.length;i++) {
        try {
             out.print("<!-- "+fileList[i]+" -->");
    %>
        <jsp:include page="<%=fileList%>" flush="true"/>
    <%
    } catch(javax.servlet.ServletException e) {
    out.println("<h3 style=\"color:red\"> Error :"+e.getMessage()+"</h3>");
    %>
    *inlude_1.jsp (This file includes another file which has some common code)*<jsp:include page="include/inlude_1.jsp" flush="true">
    <jsp:param name="magicNumberText" value="${request.adMagicNumberText}" />
    <jsp:param name="setType" value="${request.adSetType}" />
    <jsp:param name="width" value="${request.adWidth}" />
    <jsp:param name="height" value="${request.adHeight}" />
    <jsp:param name="adOuterDivClass" value="${request.adOuterDivClass}" />
    </jsp:include>
    Edited by: danbrown on Feb 9, 2009 2:49 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Good morning,
    I am not sure that could be the real problem , but I guess your app server does not like the fact that you broke the try catch in two parts. In any case, you should not do that :) Mixing code and display is very painful for maintenance :)
    Have you tried to remove the jsp:include and see if the output is correctly produced?
    Best Regards
    Edmondo

  • Jsp:include not working - Please Help.

    I am trying to do a jsp:include page but I must have the syntax wrong for the declaration of the filename. There shouldn't be a problem with my included file since it only has the word "TEST" in it. Both files are in the same directory. The error I'm getting is a 404 error.
    Message:File not found: null
    Target Servlet: File Serving Enabler
    StackTrace:
    If you look at the code, you'll see that I am doing two includes, one using the directive and one using jsp:include. The directive one comes up fine but not the jsp:include. Thanks for any help. Here's my code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
    <META name="GENERATOR" content="IBM WebSphere Page Designer V3.5.3 for Windows">
    <META http-equiv="Content-Style-Type" content="text/css">
    <TITLE>This is the page title</TITLE>
    </HEAD><BODY>
    <center>
    <table border="1">
    <tr>
    <td align="center"><jsp:include page="navigationTest2.html" flush="true"/></td>
    <td align="center"><%@ include file="navigationTest2.html" %></td>
    </tr>
    </table>
    </center>
    </BODY></HTML>

    Yeah I know, I tried that. I did notice that the directive include doesn't accept the path the same way. If I put in the full path /test/navigationTest1.html the compile would tell me couldn't read file, but the path of the file it was trying to read was /test/test/navigationTest1.html. I took the /test out and just left the / and could not read the file in the root dir, of course, because it's in the test dir. So now I have the full path /test/navigationTest1.html in the jsp:include and no path in the directive include and same results.

Maybe you are looking for

  • Unable to check for purchases, an unknown error has occured (5002)

    Unable to check for purchases, an unknown error has occured (5002) I was in the middle of download and got an error. (I didn't write down that error) I restarted Itunes and then got this error. I then upgraded to the latest patch (from 7.1 to 7.1.1)

  • The Legend of Korra not in real HD, please fix it.

    Hello, iTunes customer service: I've bought the complete season of "The Legend of Korra". It's a great series, but your video encodes are messed up. You encode the video at 960x718 aspect ratio, which is definitely not real 720p HD. Also you set the

  • Lightroom mobile sign in problem

    I have a photography subscription and can access lightroom on my desktop but not on the mobile app.  When I sign in on the mobile app (iPad) I receive a message that my subscription has expired.   I have tried reinstalling the app, signing in and out

  • How to remove paragraph JEditorPane

    Hi, I am using JEditorPane with HTMLEditorKit. But problem is that, when i press the Enter key, a paragraph will created. I need to a line break when pressing Enter . Can anyone help me, how can i remove the paragraph and insert a simple line break.

  • Necessary Matlab compiler options to integrate generated dll in VI

    What Matlab compiler (mcc) options are required for Labview to be able to import the generated dll? Using typical options, there are symbol definition problems with the header file.