Manage Learn to apply best practices and optimize your operations.

Creating good URL keys

How to create a good URL from a "bad" string containing characters that should not be in a URL.

This tip is especially useful for Domino developers developing in an environment where national characters are used, but it could be relevant to most of us, as most Domino web developers find themselves computing keys for urls that might end up containing characters that are either reserved (like "?" or "&") or which the browser or server won't accept as part of a url.

Let's say you want to compute a URL leading to a document from a persons name. For instance if you'd like my name to be clickable and to have it lead to a document containing my CV, or resume.

The URL would be something like
htp://yourserver/yourdb.nsf/people/a_key?OpenDocument
What would the key be?
It could be JensBruntt (as in @replacesubstring(thename; " "; "").

How about those annoying url-incompatible characters like the " ü" or the " ä " or how about the good old ampersand "&" which might confuse the situation as it is reserved in the Domino server? With some browsers you would get nowhere with a ü in the url.

I suggest that you look at the @password function.

@Password encodes a string from a readable format to a password format - basically just garbling up the original string. The password-string will always be the same when treating the same string. Jens Bruntt will always be converted to "(245AFE01FA27D12BBAF917BE8D3A4F0C)". Mich L?neburg will allways be "(3BFD018A4256B5C5B43B62460A5190B0)". And no non-url compatible characters in the string.

So if we compute the url like this:
"htp://yourserver/yourdb.nsf/people/" + @ReplaceSubstring(@Password(a_key); "(":")"; "") + "?OpenDocument"
and in the people view we sort the first column on @ReplaceSubstring (@Password(CV_fullname); "(":")"; "") - assuming we have my name in the CV_fullname field - you have a nice key that won't break your urls even when they contain those reserved or problematic characters.

Dig Deeper on Domino Resources - Part 3

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close