Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

We use a number of standard methods defined in dk.common.webinterface.HTMLUtils. Of particular note are the following methods:

generateHeader()_:: This method takes a PageContext and generates the full header part of the HTML page, including the starting <body> tag. It should always be used to create the header, as it also creates the menu and language selection links. After this method has been called, redirection or forwarding is no longer possible, so any processing that can cause fatal errors must be done before calling generateHeader(). The title of the page is taken from the SiteSection information based on the URL used in the request.

generateFooter()_:: This closes the HTML page and should be called as the last thing on any JSP page.

setUTF8()_:: This method must be called at the very start of the JSP page to ensure that reading from the request is handled in UTF-8.

encode()_:: This encodes any character that is not legal to have in a URL. It should be used whenever an unknown string (or a string with known illegal characters) is made part of a URL. Note that it is not idempotent, calling it twice on a string is likely to create a mess.

escapeHTML()_:: This escapes any character that has special meaning in HTML (such as < or &). It should be used any time a unknown string (or a string with known special characters) is being put into HTML. Note that it is not idempotent: If you escape something twice, you get a horrible-looking mess.

encodeAndEscape()_:: This method combines encode() and escapeHTML() in one, which is useful when you're putting unknown strings directly into URLs in HTML.

...