Skip to main content
January 22, 2008
Question

Parsing URL Variables

  • January 22, 2008
  • 2 replies
  • 596 views
I have a page (not on my server) that links to a page on my server.

This URL has several variables that I want to grab and use on my page. The URL looks like this:

http://www.somedomain.org/test.cgi?id=ABC&isbn=1234&volume=82

By using cgi.HTTP_REFERER I am able to display the URL, but I am having trouble parsing out the variables to use later on the page.

How do I "grab" the values of id, isbn, and volume from this URL?

Thank you for your help.
Alison
This topic has been closed for replies.

2 replies

Inspiring
January 22, 2008
alison@ut wrote:
> I have a page (not on my server) that links to a page on my server.
>
> This URL has several variables that I want to grab and use on my page. The
> URL looks like this:
>
> http://www.somedomain.org/test.cgi?id=ABC&isbn=1234&volume=82
>
> By using cgi.HTTP_REFERER I am able to display the URL, but I am having
> trouble parsing out the variables to use later on the page.
>
> How do I "grab" the values of id, isbn, and volume from this URL?
>
> Thank you for your help.
> Alison
>

Most of us would use url.id, url.isbn and url.volume. You could also
use url['id'], url['isbn'] and url['volume'] if you like on any version
of ColdFusion released this century.

<cfdump var="#url#"> may also be informative.

I.E. you are working to hard if you are trying to parse
cgi.http_REFERER. ColdFusion has already done this and dumped
everything into the URL structure. Of course, if I was going to use a
CGI variable, I would use cgi.query_string and parse as nested lists.

But is 'test.cgi' a ColdFusion template?

January 22, 2008
Thank you both for your replies!

The referring page is not a CF page, so i guess I will need to parse the URL using cgi.query_string. I will look for information on how to do that since I have never used that before.

Thanks again!
Alison
Inspiring
January 22, 2008
Use list functions. The url is a nested list. The outer list has an ampersand delimiter and the inner lists have an equal sign delimiter.