[opencms-dev] URL encode with Umlauts

Christoph Kukulies kuku at physik.rwth-aachen.de
Fri Jul 7 13:05:43 CEST 2017


I have a jsp which reads an URL from a database and oututs it to a page


like <a href="/dir/Übersicht.htm">Übersicht</a>

(as a side note: the page resides in opencms, so it's relative to the 
/index.html (which is the main page)

When I click on that link in a browser, the URL cannot be found

All URLs that do not contain an Umlaut (ä,ö,ü,Ä,Ö,Ü,ß) are resolved fine.

This is the piece of code:


    rs = st.executeQuery("SELECT url,urlname,kommentar,ok,ID from urls");

               while(rs.next()) {

                 if(rs.getString(4).equals("1"))
                     ok="ok";
                 else ok="notok";
                  // String url = URLEncoder.encode(
                    //  rs.getString(1),
                      // "ISO-8859-1"
                   // );
                   String url=rs.getString(1);
                 out.println("\n" +  "<form action=\"#\"><span 
class=\""+ok+"\"><a href=\""
                 + url + "\" target=\"right\" >"
                 + rs.getString(2) + "</a><span class=\"rt\"><textarea  
name=\"kommentar\" style=\"height:15px;width:250px;\" rows=\"1\" 
cols=\"40\" >"
                 + rs.getString(3)+"</textarea><input type=\"hidden\" 
name=\"ID\" value=\""
                 + rs.getString(5)+"\"/><button type=\"submit\" 
name=\"ok\" value=\"1\" >ok</button><button type=\"submit\" name=\"ok\" 
value=\"0\">n.ok.</button></span></span></form>");
               }
                if(rs!=null)rs.close();
                if(st!=null)st.close();
                if(st1!=null)st1.close();
                if(c!=null) c.close();

The commented out stuff (//) does not work.

When I hover over the link in the browser the url (not the encoded on) 
looks like:

cms.mysite.org/dir/Übersicht.html

for example. That is, the hostname (without http://) is in the href 
field of the anchor element.

Any clues?

--

Christoph


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20170707/ea26e577/attachment.htm>


More information about the opencms-dev mailing list