request.setCharacterEncoding("UTF-8");
String text = request.getParameter("text");
String url = request.getParameter("url");
String encoded = "";
Transcoder transcoder = getTranscoder();
// the URL form has been submitted
if (url != null && !url.trim().isEmpty()) {
// Catch the last part of the URL if necessary
Matcher m1 = URL_PATTERN.matcher(url);
if (m1.find()) {
url = m1.group(1);
}
// Check it's a valid compressed text
Matcher m2 = ENCODED_PATTERN.matcher(url);
if (m2.find()) {
url = m2.group(0);
text = transcoder.decode(url);
} else {
System.out.println("PlantUML ERROR Not a valid compressed string : " + url);
}
}
// the Text form has been submitted
if (text != null && !text.trim().isEmpty()) {
encoded = transcoder.encode(text);
}
request.setAttribute("decoded", text);
request.setAttribute("encoded", encoded);