Forum OpenACS Q&A: ad_returnredirect

Collapse
Posted by Jason Simpson on
Hello,

I'm using the ad_returnredirect function and i'm getting weird results coming about

This is the code in my update_page.tcl page

ad_page_contract {
  Update page
} {
  page_id:notnull
  page_link:notnull
}

db_dml update_page { *SQL* }

ad_returnredirect $page_link
ad_script_abort

Here page_link is an external URL, like http://www.google.com

It performs the SQL function properly, but when it comes to the ad_returnredirect page, it simply goes back to the index.adp page

If i used ns_returnredirect instead, it provides me a link to click on to get to the URL, but i want it to go there straight away

Can anyone tell me why it keeps returning to the index page? and Not recognising page_link?

Jas

Collapse
2: Re: ad_returnredirect (response to 1)
Posted by Jade Rubick on
Jas, do you get the same result on all browsers?

What port is your webserver listening on?

Collapse
3: Re: ad_returnredirect (response to 2)
Posted by Tilmann Singer on
Doing a

ad_returnredirect "http://www.google.com"

works for me. Maybe you are not getting the value in $page_link that you expect? If it is an empty string then the redirect will go to the index page of the current location I think.

You could for example try to replace

ad_returnredirect $page_link

with

doc_return 200 text/plain "page_link is: $page_link"

to see what it contains.

Collapse
4: Re: ad_returnredirect (response to 3)
Posted by Jason Simpson on
i get a value for $page_link

when i do doc_return 200 text/plain "page_link is: $page_link" i get the url showing

however, when i do

ns_write $page_link

before redirecting I get nothing, but if I do:

ns_write "test"
ns_write $page_link

i get 'hello' followed by the link

so it seems that ad_returnredirect $page_link will not detect the value of $page_link, but anything else (i.e. ns_returnredirect $page_link will detect it)

if i do ad_returnredirect "http://www.google.com" it sends the page to Google correctly

is this an error with ad_returnredirect? or just me?

Collapse
5: Re: ad_returnredirect (response to 4)
Posted by Jason Simpson on
figured it out...finally!!!

was truncating the page_link before inserting into database, so link was never correct