Mattias Jiderhamn wrote:
>
> I have a problem... like most people on this list :-)
>
> In some cases we let our customers define the keys for database entries.
> For example they might define the keys for the database of (their)
> customers. It is very possible they sometime would like to use a
> national character, any of the Swedish � � �.
> I want to have a dynamic link where you can delete a DB entry, and then
> this key needs to be a parameter. Say
> <a href="customerDelete.jsp?key=CUSTOMER1">Delete</a>
>
> Now if the key includes national (Swedish) characters, I only get the
> part before those characters.
> key=BR�DBUTIK gives me just key=BR
>
> I have found a way around. To use a form with a hidden field and the
> method POST. But there lots of extra code which both takes time to write
> and clutters down the page.
>
> 1)
> Does anybody know of some other way around?
> Can you encode the link? (I have tried encodeUrl(), but it doesn't
> change a thing).
> Can you change the encoding of the request?
>
> 2)
> Is the problem in the HTTP- protocol or is it in the Java part (JSP
> specs, Tomcat)?
> Could it help to change JSP container?
For links with query string parameters that can contain special characters,
you need to URL encode the parameters with the java.net.URLEncoder.encode()
method. The HttpServletResponse.encodeURL() method that you have tried to
use doesn't encode special characters, it embeds a session ID for session
tracking (if needed) in the URL.
As a side note, you may want to use a numeric key instead of a string
provided by your users to avoid this problem (and possible other problems,
like key collisions). A user friendly name can be defined as a regular
column in the database and used in the user interface in place of the
internally maintained numeric key.
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets