This challenge has made me create three different solutions all present in the comments, but I'll show where they are within my custom Web Framework:
dewd@rubynho:~/code/libraries/web_rules/examples/arcchallenge$ ls
jsp_said.rtj php_said.rtj said.rb
The cool thing is that they work simultaneously, just like multiple "php pages" would in a PHP setup. The future should look like this in my opinion. :-)
I've been able to create one using Ruby and my Web Framework like this:
tt = [
'<form method="POST"><input name="t" /><input type="submit" name="OK"></form>',
'<a href="said?show=1">click here.</a>',
"you said: #{@w.session['t']}"
]
ti = 0
if @w.f(:OK)
@w.session['t'] = @w.f(:t)
ti = 1
elsif @w.q(:show)
@w.session['do_show'] = true
@w.redirect 'said'
elsif @w.session['do_show']
@w.session['do_show'] = nil
ti = 2
end
@w.content = tt[ti]
I'm not sure how other folks will solve it though. It's interesting that my Web Framework has support for both pure Ruby like this, and for a templated approach similar to PHP but using Tenjin:
* http://www.kuwata-lab.com/tenjin/
I wanted to keep it all in one URL and without template for this though. I'm not sure I'd normally program it like that, as I enjoy multiple pages and URLs. Anyway, many ways to skin a cat, and Arc did good.
P.S. In the past my framework had a more "programming" approach which was based on ideas I grasped from Wee which was itself based on Seaside. But since it has been dropped, but your challenge reminds me of it.