tags:

views:

863

answers:

2

In a Grails application I'd like to send a user from page A, then to a form on page B and then back to page A again.

To keep track of which URL to return to I send a "returnPage" parameter to page B containing the URL of page to return to (page A).

Currently I'm using request.getRequestURL() on page A to retrieve the page's URL. However, the URL I get from getRequestURL() does not correspond to the URL the end-user has in his/hers address bar:

request.getRequestURL() == "http://localhost:8080/something/WEB-INF/grails-app/views/layouts/main.gsp"
URL in address bar == "http://localhost:8080/something/some/thing"

How do I obtain the "end-user" URL?

+5  A: 

The answer is request.forwardURI (details here).

knorv
A: 

When creating the link to page B you can use the createLink tag to set the returnPage parameter:

<g:link controller="pageB" 
        action="someaction" 
        params='[returnPage:createLink(action:actionName, params:params)]'>
  Go to Page B
</g:link>
John Wagenleitner