Let's see how we can get some information from the user, shall we?
1. Create a file named
product.cfm
in your<Railo Install Directory>/webroot/myApp/
folder.2. Run that file in your browser with the following URL:
http://localhost:8888/myApp/product.cfm
, and you will get a blank page.3. Now let's add the following code:
<cfoutput> The product you requested is #url.productid# </cfoutput>
Now let's browse to the page with the following: http://localhost:8888/myApp/product.cfm?productid=1234
. You will now see "The product you requested is 1234" displayed on the page.
It is that simple to access variables passed in the URL; all you have to do is to reference the URL scope.
But what happens if we remove the ?productid=1234
from the URL? Oh dear! We get an error!
Our applications should be a bit more robust, right? Thankfully, we can easily fix that with a simple tag. Let's update our code here:
<cfparam name="URL.productid...