Sign in

E-mail *, (xx@domain.com)
Password *

Register | Forgot password

Recent blogs

RSS - Blogs
March 9, 2010
State of OSGi in the Java world
March 4, 2010
Reach more people with Google Translate
March 3, 2010
Get My Advice
February 26, 2010
What? Where!?!
February 11, 2010
Split it!

All Blogs...


All amped up

May 20, 2008

I am still recovering from the 26th installment of the local festival "Day of the Life Song". Ten hours of drinking and singing, so blogging comes kind of natural at this time. :-)


For lovers of the Day of the Life Song, a photo that I saw on some CTO's feed:

Der Keyboard Superstar

Der Keyboard Superstar live in action!


Off topic: terrible translation "life song" for "levenslied". I tried "tear jerker" but that is not making it any better. Suggestions for good translations are welcome.


In the last few weeks the ampersand (the character '&') has been trying to catch my attention. As you may know, the page you are looking at is defined in HTML. In HTML, the '&' is used as escape character for HTML-entities, much like the backslash (\) in Java strings or the single quote (') in SQL strings. Whenever you encounter strange things in HTML, you are supposed to escape them to their entities. If you don't Bad Things (tm) might happen (and in fact they do when exporting XML output for RSS readers)!


Below are some escaping examples:

String test = "Look mom, a backslash (\\)"; // Java
SELECT 'Look mom, a single quote ('')' -- SQL
<b>Look mom, an ampersand (&amp;)</b> <!-- HTML -->

So far, so good!

Enters the content. In particular: URLs. Below are a few examples taken from this site:


http://www.gxdeveloperweb.com/Blogs.htm
http://www.gxdeveloperweb.com/Forums/Forum-WCB-Java-Development.htm?fc=4-160&forum=4&message=160

As you can see, the latter URL contains ampersands. While a URL does not need to be escaped in the address bar of your browser, it does need to be escaped in the HTML source code that builds a link for you. The source for that last URL should read:

<a href="/Forums/Forum-WCB-Java-Development.htm?fc=4-160&amp;forum=4&amp;message=160">link</a>

Which it actually does! I must confess I am amazed, because not many people are true escape artists. This is fuelled by browsers that allow you to be sloppy.

Yay! GX WebManager correctly escapes internal links! External links it does not touch, though. You will have to escape those ampersands manually.


Not all shines, though. The HTML validator still detects plenty of unescaped ampersands in the HTML source of this website, probably the result of mistakes in the design JSP files. Which only goes to illustrate that it is good to check, check, and doublecheck again!

Keep an eye out for them ampersands... Till next time!


Greetings,


Patrick


About the Author

Return to all blogs

 

Patrick Atoon

Patrick Atoon has gained nuff respect as one of the most experienced web architects in the GX Webmanager community or even the global hip hop community for that matter.

Read all Patricks blog entries

Other blog entries:

February 26, 2010
What? Where!?!
September 3, 2009
Do the Right Thing
June 18, 2009
wm:link secrets
March 2, 2009
Server side represent! (Part 2)
February 4, 2009
Server side represent!
January 15, 2009
Making cache
December 9, 2008
Like A Version
August 19, 2008
Stop making sense
August 4, 2008
Namaste!
July 7, 2008
Japanese encore (日本のアンコール)


Share:

del.icio.us
digg
Technorati
Slashdot
Reddit
YahooMyWeb
NewsVine
ekudos
© 2010 GX creative online development B.V.

Disclaimer

This website (GXdeveloperweb.com) may discuss or contain opinions, (sample) coding, software or other information that does not include GX official interfaces, instructions or guidelines and therefore is not supported by GX. Changes made based on this information are not supported.  GX will not be held liable for any damages caused by using or misusing the information, software, instructions, code or methods suggested on this website, and anyone using these methods does so at his/her own risk. GX offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this website, including any liability resulting from incompatibility between the content of this website and the materials and services offered by GX. By using this website you will not hold, or seek to hold, GX responsible or liable with respect to the content of this website.