Uploaded image for project: 'Struts 1'
  1. Struts 1
  2. STR-2905

Allow nested tags <include ..> inside an action (<action ...></action>)

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.2.9
    • Future
    • Core
    • None
    • System: Microsoft Windows XP (Version 2002 - Service Pack 2)
      App Server: Tomcat 5.5.9
      Struts Version; 1.2.9

    Description

      I know that is possible to do an include instead of a forward, but it's only possible to use in declarations like this:

      ...
      <action path="/something" include="/path/to/my/file.jsp" />
      ...

      So, if I need to do an include using an action that has more than one forward and/or include, I can't!!!

      ...
      <action type="myClass" ... />
      <forward name="f1" path="/f1.jsp" /> <!-- This need to be an include. What can I do? -->
      <forward name="f2" path="/f2.jsp" />
      <forward name="f3" path="/f3.jsp" />
      </action>
      ...

      Why do I have to do this? Suppose that I need to do a server push. The most common use of server push, is show a message (Splash Screen) for the user while the system is processing something else. And then, when the process is done, the system do an include showing the desire result. But, as I said, to do this, we have to do an include, because if we use a forward an error will occur, due to fact that we can't forward a request if we already response something.

      So for actions with more than one forwards we can't use the server push! I guess. First, because the <forward ../> tag doesn't have any attribute that tells that this forward should be an include. And second, because doesn't exist any nested tag like <include ../> to replace the <forward ../> tag inside the action.

      I don't know if exists any problem in use this approach, i.e., add the <include ../> tag to struts DTD, and in the Request Processor add a verification if it needs to do a forward or an include. Like is done with single action, showed in the first example above. So, if we use the first example, the Request Processor verifies if it needs to do an forward, if not then it verifies if it needs to do an include. As you can see in follow piece of code:

      ...
      public void process(HttpServletRequest request, HttpServletResponse response) {
      ...
      if (!processForward(request, response, mapping))

      { return; }

      if (!processInclude(request, response, mapping)) { return; }

      ...
      }
      ...

      But if we have to do anything like what was showed in the second example, we can't.

      I realize with this solution of adding the tag <include>, we still have the backward compatibility and an improvement to setup an include on actions with multiples forwards/includes.

      Felipe

      Attachments

        Activity

          People

            Unassigned Unassigned
            desiderati Felipe Desiderati e Souza
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: