DarkKnightFan
DarkKnightFan

Reputation: 1953

struts2: display result jsp in the main/calling jsp

I have a one main jsp (file upload jsp screen) which has form elements. User will select the file to upload, also set some other elements (such as checkboxes, radios, etc.) as per the requirement and then finally submit the form.

After uploading the result of the process is formulated into a table of a different JSP (say result.jsp). Right now the result.jsp is displayed independently on the screen.

What I want is to display the result.jsp in the same parent.jsp (having form elements) and not on a separate independent page.

Can anyone help me with this?

struts.xml:

<action name="commonDataImportAction_*" class="commonDataImportAction">
        <result name="VIEW">
            /jsp/CommonDataImportLog.jsp (result.jsp)
        </result>
        <result name="input">/jsp/CommonDataImport.jsp (parent.jsp)
        </result>
</action>

Update:

Screenshot of the screen, how I want it:

http://img802.imageshack.us/img802/7141/screenzgk.jpg

Upvotes: 0

Views: 1497

Answers (2)

SKJ
SKJ

Reputation: 46

As i found u have to redirect it to same page (parent.jsp). You have to remove another one.

And make some change in parent.jsp. Like use of iterator tag and all which is useful for display all your data.

Upvotes: 0

Umesh Awasthi
Umesh Awasthi

Reputation: 23587

If you are submitting the page in simple manner the way Struts2 submit button works than one simple solution is to create only a single page which also contains the layout of your result.jsp, but you can hide that part initially (before the page submit).

On successful page submission you can set a value (say a Boolean) in your action class and based on this can show that section,since your are already done with file upload so you can set those values in your action class which are needed to show the values in result.jsp.

For me that is a simple yet efficient approach.

Alternatively if you are going with the Ajax based file upload than there are many ways to do this like

  1. Send back HTML section from the Action.
  2. You can even send the name of JSP file and can include it in to the current JSP at runt time.
  3. Send JSON data from action and parse the JSON using Jquery to build view

Upvotes: 2

Related Questions