You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Qunhuan Mei <qm...@qm18.wanadoo.co.uk> on 2009/04/24 18:27:24 UTC

Redirect problem using Ajax and Struts - missing directory for image access

Hi there, 

 

My app uses Struts 2.1.6 to handle user’s file upload. It creates a user specific directory, say userDir at rumtime before upload starts. The userDir stores user uploaded files, say an intro.html with images. 

 

The app uses GDownloadUrl (google’s ajax) to access the intro.html in a redirect way, i.e. the GDownload sends a http://serverURL/getIntro.action to the server and server figures out the userDir and redirect to userDir/intro.html, (http://serverURL/userDir/intro.html)

 

The intro.html gets to the browser ok but the images within intro.html, e.g. <img src=”example.jpg”/> does not work. The request for image appears to be http://serverURL/intro.html with userDir always missing.

 

In order to make sure the intor.html and image does work on its own, I have tested:

 

1.       index.html redirect, e.g. to include the following in the index.html file:

<META HTTP-EQUIV="Refresh" CONTENT="0;URL=userDir/intro.html">

It works fine, the image gets rendered.

2.       straight browser action request (e.g. http://serverURL/getIntro.actoin) without using GDownload and then use struts.xml to redirect: 

<result name="success" type="redirect">/userDir/intro.html</result>

This works fine, the image gets rendered.

 

Is there any way this problem could be corrected or avoided? The only option I have is to add userDir to the image reference for intro.html but this is a pain for me. 

 

Could anyone help please?

 

Qunhuan