6-Nov-04 (Created: 6-Nov-04) | More in 'Howto'

How can I redirect a page to different urls after an update

Prerequisites

You have to use the RequestExecutorServeletT2 in your web.xml and your build should be build 20 or above.

Please read this link for further instructions on the needed property file entries

Using the aspire_target_url_key

Currently the following URL


request.server-side-request.redirectURL={aspireContext}/page1?url=abcURL

will redirect to page1 after successfully executing the server-side-request. Now imagine the following scenario


request.server-side-request.redirectURL.page1={aspireContext}/display?url=page1URL
request.server-side-request.redirectURL.page2={aspireContext}/display?url=page2URL
request.server-side-request.redirectURL.page3={aspireContext}/display?url=page3URL

In this scenario you want to redirect the user to potentially one of three possibilities. You can do this by giving a url like the following


/your-app/update?request_name=server-side-request&aspire_target_url_key=page1&arg1=xyz

Notice that the aspire_target_url_key is pointing to page1. Aspire will go to page1URL on successful execution. In that sense the aspire_target_url_key points to a key off of redirectURL to redirect to.

Using substitutions for effectiing the same

You can also use the basic substitution support to go to a different page as well. Here is how this works.


request.server-side-request.redirectURL.page1={aspireContext}/display?url={target-page}

Now you can send in a url like the following


/your-app/update?request_name=server-side-request&target-page=page1URL&arg1=xyz

Which is better to use?

The aspire_target_url_key method gives you more clarity and flexibility. But for simpler urls the substitution method might work quite as well and may be a bit simpler.

References

1. How to do updates in Aspire

2. Some notes on updates