update jetty and tomcat to latest version

This commit is contained in:
Florian
2021-10-15 15:11:55 +02:00
committed by arnaudroques
parent b1b7dfb84b
commit 9cb9cec6ca
30 changed files with 1693 additions and 611 deletions

77
src/main/config/jetty.xml Normal file
View File

@@ -0,0 +1,77 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
<!-- =============================================================== -->
<!-- Configure a Jetty Server instance with an ID "Server" -->
<!-- Other configuration files may also configure the "Server" -->
<!-- ID, in which case they are adding configuration to the same -->
<!-- instance. If other configuration have a different ID, they -->
<!-- will create and configure another instance of Jetty. -->
<!-- Consult the javadoc of o.e.j.server.Server for all -->
<!-- configuration that may be set here. -->
<!-- =============================================================== -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Http Configuration. -->
<!-- This is a common configuration instance used by all -->
<!-- connectors that can carry HTTP semantics (HTTP, HTTPS, etc.)-->
<!-- It configures the non wire protocol aspects of the HTTP -->
<!-- semantic. -->
<!-- -->
<!-- This configuration is only defined here and is used by -->
<!-- reference from other XML files such as jetty-http.xml, -->
<!-- jetty-https.xml and other configuration files which -->
<!-- instantiate the connectors. -->
<!-- -->
<!-- Consult the javadoc of o.e.j.server.HttpConfiguration -->
<!-- for all configuration that may be set here. -->
<!-- =========================================================== -->
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
<Set name="secureScheme" property="jetty.httpConfig.secureScheme"/>
<Set name="securePort" property="jetty.httpConfig.securePort"/>
<Set name="outputBufferSize" property="jetty.httpConfig.outputBufferSize"/>
<Set name="outputAggregationSize" property="jetty.httpConfig.outputAggregationSize"/>
<Set name="requestHeaderSize" property="jetty.httpConfig.requestHeaderSize"/>
<Set name="responseHeaderSize" property="jetty.httpConfig.responseHeaderSize"/>
<Set name="sendServerVersion" property="jetty.httpConfig.sendServerVersion"/>
<Set name="sendDateHeader"><Property name="jetty.httpConfig.sendDateHeader" default="false"/></Set>
<Set name="headerCacheSize" property="jetty.httpConfig.headerCacheSize"/>
<Set name="delayDispatchUntilContent" property="jetty.httpConfig.delayDispatchUntilContent"/>
<Set name="maxErrorDispatches" property="jetty.httpConfig.maxErrorDispatches"/>
<Set name="persistentConnectionsEnabled" property="jetty.httpConfig.persistentConnectionsEnabled"/>
<Set name="httpCompliance"><Call class="org.eclipse.jetty.http.HttpCompliance" name="from"><Arg><Property name="jetty.httpConfig.compliance" deprecated="jetty.http.compliance" default="RFC7230"/></Arg></Call></Set>
<!-- Changed from "SAFE" to "DEFAULT,AMBIGUOUS_EMPTY_SEGMENT" -->
<Set name="uriCompliance"><Call class="org.eclipse.jetty.http.UriCompliance" name="from"><Arg><Property name="jetty.httpConfig.uriCompliance" default="DEFAULT,AMBIGUOUS_EMPTY_SEGMENT"/></Arg></Call></Set>
<Set name="requestCookieCompliance"><Call class="org.eclipse.jetty.http.CookieCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.requestCookieCompliance" default="RFC6265"/></Arg></Call></Set>
<Set name="responseCookieCompliance"><Call class="org.eclipse.jetty.http.CookieCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.responseCookieCompliance" default="RFC6265"/></Arg></Call></Set>
<Set name="relativeRedirectAllowed"><Property name="jetty.httpConfig.relativeRedirectAllowed" default="false"/></Set>
<Set name="useInputDirectByteBuffers" property="jetty.httpConfig.useInputDirectByteBuffers"/>
<Set name="useOutputDirectByteBuffers" property="jetty.httpConfig.useOutputDirectByteBuffers"/>
</New>
<New id="httpConnectionFactory" class="org.eclipse.jetty.server.HttpConnectionFactory">
<Arg name="config"><Ref refid="httpConfig" /></Arg>
</New>
<New id="httpConnector" class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server"><Ref refid="Server" /></Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<Item>
<Ref refid="httpConnectionFactory" />
</Item>
</Array>
</Arg>
<!-- Change port according to property. Default is 8080 -->
<Set name="port"><Property name="jetty.http.port" deprecated="jetty.port" default="8080" /></Set>
</New>
<!-- =========================================================== -->
<!-- Add http Connector -->
<!-- =========================================================== -->
<Call name="addConnector">
<Arg><Ref refid="httpConnector" /></Arg>
</Call>
</Configure>

View File

@@ -26,10 +26,11 @@ package net.sourceforge.plantuml.servlet;
import java.io.IOException;
import javax.imageio.IIOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.servlet.utility.UmlExtractor;

View File

@@ -23,30 +23,30 @@
*/
package net.sourceforge.plantuml.servlet;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.ByteArrayOutputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.sourceforge.plantuml.BlockUml;
import net.sourceforge.plantuml.ErrorUml;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.NullOutputStream;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.SourceStringReader;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.code.Base64Coder;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.version.Version;
import net.sourceforge.plantuml.error.PSystemError;
import net.sourceforge.plantuml.ErrorUml;
import net.sourceforge.plantuml.version.Version;
/**
* Delegates the diagram generation from the UML source and the filling of the HTTP response with the diagram in the

View File

@@ -23,15 +23,16 @@
*/
package net.sourceforge.plantuml.servlet;
import net.sourceforge.plantuml.syntax.LanguageDescriptor;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintStream;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.sourceforge.plantuml.syntax.LanguageDescriptor;
/**
* Servlet used to inspect the language keywords of the running PlantUML server.
* Same as {@code java -jar plantuml.jar -language}

View File

@@ -26,10 +26,11 @@ package net.sourceforge.plantuml.servlet;
import java.io.IOException;
import javax.imageio.IIOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.servlet.utility.UmlExtractor;

View File

@@ -31,10 +31,10 @@ import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;

View File

@@ -31,17 +31,20 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.net.ssl.HttpsURLConnection;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.api.PlantumlUtils;
import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderUtil;
import net.sourceforge.plantuml.png.MetadataTag;
import net.sourceforge.plantuml.servlet.utility.Configuration;
import net.sourceforge.plantuml.servlet.utility.UmlExtractor;
/**
* Original idea from Achim Abeling for Confluence macro.
@@ -81,62 +84,36 @@ public class PlantUmlServlet extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
String text = request.getParameter("text");
String metadata = request.getParameter("metadata");
if (metadata != null) {
InputStream img = null;
try {
img = getImage(new URL(metadata));
MetadataTag metadataTag = new MetadataTag(img, "plantuml");
String data = metadataTag.getData();
if (data != null) {
text = data;
}
} finally {
if (img != null) {
img.close();
}
}
}
try {
text = getTextFromUrl(request, text);
} catch (Exception e) {
e.printStackTrace();
}
// textual diagram source
final String text = getText(request).trim();
// no Text form has been submitted
if (text == null || text.trim().isEmpty()) {
if (text.isEmpty()) {
redirectNow(request, response, DEFAULT_ENCODED_TEXT);
return;
}
final String encoded = getTranscoder().encode(text);
request.setAttribute("decoded", text);
request.setAttribute("encoded", encoded);
// check if an image map is necessary
if (text != null && PlantumlUtils.hasCMapData(text)) {
request.setAttribute("mapneeded", Boolean.TRUE);
}
// forward to index.jsp
prepareRequestForDispatch(request, text);
final RequestDispatcher dispatcher = request.getRequestDispatcher("/index.jsp");
dispatcher.forward(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
protected void doPost(
HttpServletRequest request,
HttpServletResponse response
) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
String text = request.getParameter("text");
String encoded = DEFAULT_ENCODED_TEXT;
// encoded diagram source
String encoded;
try {
text = getTextFromUrl(request, text);
String text = getText(request).trim();
encoded = getTranscoder().encode(text);
} catch (Exception e) {
encoded = DEFAULT_ENCODED_TEXT;
e.printStackTrace();
}
@@ -144,16 +121,59 @@ public class PlantUmlServlet extends HttpServlet {
}
/**
* Get textual diagram source from URL.
* Get textual diagram.
* Search for textual diagram in following order:
* 1. URL {@link PlantUmlServlet.getTextFromUrl}
* 2. metadata
* 3. request parameter "text"
*
* @param request http request which contains the source URL
* @param text fallback textual diagram source
* @param request http request
*
* @return if successful textual diagram source from URL; otherwise fallback {@code text}
* @return if successful textual diagram source; otherwise empty string
*
* @throws IOException if an input or output exception occurred
*/
private String getTextFromUrl(HttpServletRequest request, String text) throws IOException {
private String getText(final HttpServletRequest request) throws IOException {
String text;
// 1. URL
try {
text = getTextFromUrl(request);
if (text != null && !text.isEmpty()) {
return text;
}
} catch (Exception e) {
e.printStackTrace();
}
// 2. metadata
String metadata = request.getParameter("metadata");
if (metadata != null) {
try (InputStream img = getImage(new URL(metadata))) {
MetadataTag metadataTag = new MetadataTag(img, "plantuml");
String data = metadataTag.getData();
if (data != null) {
return data;
}
}
}
// 3. request parameter text
text = request.getParameter("text");
if (text != null && !text.isEmpty()) {
return text;
}
// nothing found
return "";
}
/**
* Get textual diagram source from URL.
*
* @param request http request which contains the source URL
*
* @return if successful textual diagram source from URL; otherwise empty string
*
* @throws IOException if an input or output exception occurred
*/
private String getTextFromUrl(HttpServletRequest request) throws IOException {
final Matcher recoverUml = RECOVER_UML_PATTERN.matcher(
request.getRequestURI().substring(request.getContextPath().length())
);
@@ -171,8 +191,75 @@ public class PlantUmlServlet extends HttpServlet {
}
return getTranscoder().decode(url);
}
// fallback
return text;
// nothing found
return "";
}
/**
* Prepare request for dispatch and get request dispatcher.
*
* @param request http request which will be further prepared for dispatch
* @param text textual diagram source
*
* @throws IOException if an input or output exception occurred
*/
private void prepareRequestForDispatch(HttpServletRequest request, String text) throws IOException {
// diagram sources
final String encoded = getTranscoder().encode(text);
request.setAttribute("decoded", text);
request.setAttribute("encoded", encoded);
// properties
request.setAttribute("showSocialButtons", Configuration.get("SHOW_SOCIAL_BUTTONS"));
request.setAttribute("showGithubRibbon", Configuration.get("SHOW_GITHUB_RIBBON"));
// URL base
final String hostpath = getHostpath(request);
request.setAttribute("hostpath", hostpath);
// image URLs
final boolean hasImg = !text.isEmpty();
request.setAttribute("hasImg", hasImg);
request.setAttribute("imgurl", hostpath + "/png/" + encoded);
request.setAttribute("svgurl", hostpath + "/svg/" + encoded);
request.setAttribute("txturl", hostpath + "/txt/" + encoded);
request.setAttribute("mapurl", hostpath + "/map/" + encoded);
// map for diagram source if necessary
final boolean hasMap = PlantumlUtils.hasCMapData(text);
request.setAttribute("hasMap", hasMap);
String map = "";
if (hasMap) {
try {
map = UmlExtractor.extractMap(text);
} catch (Exception e) {
e.printStackTrace();
}
}
request.setAttribute("map", map);
}
/**
* Get hostpath (URL base) from request.
*
* @param request http request
*
* @return hostpath
*/
private String getHostpath(final HttpServletRequest request) {
// port
String port = "";
if (
(request.getScheme() == "http" && request.getServerPort() != 80)
||
(request.getScheme() == "https" && request.getServerPort() != 443)
) {
port = ":" + request.getServerPort();
}
// scheme
String scheme = request.getScheme();
final String forwardedProto = request.getHeader("x-forwarded-proto");
if (forwardedProto != null && !forwardedProto.isEmpty()) {
scheme = forwardedProto;
}
// hostpath
return scheme + "://" + request.getServerName() + port + request.getContextPath();
}
/**

View File

@@ -29,11 +29,17 @@ import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.cert.Certificate;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.imageio.IIOException;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLPeerUnverifiedException;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.sourceforge.plantuml.BlockUml;
import net.sourceforge.plantuml.FileFormat;
@@ -42,13 +48,6 @@ import net.sourceforge.plantuml.SourceStringReader;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.UmlSource;
import java.security.cert.Certificate;
import java.util.List;
import javax.imageio.IIOException;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLPeerUnverifiedException;
/**
* Proxy servlet of the webapp.
* This servlet retrieves the diagram source of a web resource (web html page)

View File

@@ -23,20 +23,21 @@
*/
package net.sourceforge.plantuml.servlet;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.servlet.utility.UmlExtractor;
import javax.imageio.IIOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.imageio.IIOException;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.servlet.utility.UmlExtractor;
/**
* Common service servlet to produce diagram from compressed UML source contained in the end part of the requested URI.
*/

View File

@@ -1,53 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* Project Info: https://plantuml.com
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
package net.sourceforge.plantuml.servlet;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Welcome servlet of the webapp.
* Displays the sample Bob and Alice sequence diagram.
*/
@SuppressWarnings("SERIAL")
public class Welcome extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// set the sample
request.setAttribute("decoded", "Bob -> Alice : hello");
request.setAttribute("encoded", "SyfFKj2rKt3CoKnELR1Io4ZDoSa70000");
// forward to index.jsp
RequestDispatcher dispatcher = request.getRequestDispatcher("/index.jsp");
dispatcher.forward(request, response);
}
}

View File

@@ -85,10 +85,10 @@ public final class Configuration {
* @return true if the value is "on"
*/
public static boolean get(final String key) {
if (instance.config.getProperty(key) == null) {
if (get().getProperty(key) == null) {
return false;
}
return instance.config.getProperty(key).startsWith("on");
return get().getProperty(key).startsWith("on");
}
}

View File

@@ -27,9 +27,14 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.SourceStringReader;
import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderUtil;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.ImageData;
/**
* Utility class to extract the UML source from the compressed UML source contained in the end part
@@ -84,4 +89,36 @@ public abstract class UmlExtractor {
return uml;
}
/**
* Get image map from uml.
*
* @param uml textual diagram source
*
* @return image map of the diagram in HTML format if the image has some position information; otherwise `null`
*
* @throws IOException if an input or output exception occurred
*/
public static String extractMap(final String uml) throws IOException {
return extractMap(uml, FileFormat.PNG);
}
/**
* Get image map from uml.
*
* @param uml textual diagram source
* @param fileFormat underlying file format of uml image
*
* @return image map of the diagram in HTML format if the image has some position information; otherwise `null`
*
* @throws IOException if an input or output exception occurred
*/
public static String extractMap(final String uml, final FileFormat fileFormat) throws IOException {
Diagram diagram = new SourceStringReader(uml).getBlocks().get(0).getDiagram();
ImageData map = diagram.exportDiagram(new NullOutputStream(), 0, new FileFormatOption(fileFormat, false));
if (map.containsCMapData()) {
return map.getCMapData("plantuml");
}
return null;
}
}

View File

@@ -0,0 +1,6 @@
# Logger configuration file
#
log4j.rootCategory=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yy-MM-dd HH:mm:ss:SSS} %5p %t %c{2}:%L - %m%n

View File

@@ -1,150 +1,219 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>plantuml</display-name>
<context-param>
<param-name>org.eclipse.jetty.servlet.Default.welcomeServlets</param-name>
<param-value>exact</param-value>
</context-param>
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.7</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.7</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>plantumlservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.PlantUmlServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>welcome</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.Welcome</servlet-class>
</servlet>
<servlet>
<servlet-name>imgservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.ImgServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>svgservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.SvgServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>epsservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.EpsServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>epstextservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.EpsTextServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>base64servlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.Base64Servlet</servlet-class>
</servlet>
<servlet>
<servlet-name>asciiservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.AsciiServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>proxyservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.ProxyServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>oldproxyservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.OldProxyServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>mapservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.MapServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>checkservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.CheckSyntaxServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>languageservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.LanguageServlet</servlet-class>
</servlet>
<!-- Patterns of the servlet -->
<servlet-mapping>
<servlet-name>plantumlservlet</servlet-name>
<url-pattern>/welcome</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>plantumlservlet</servlet-name>
<url-pattern>/uml/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>plantumlservlet</servlet-name>
<url-pattern>/form</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>imgservlet</servlet-name>
<url-pattern>/png/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>imgservlet</servlet-name>
<url-pattern>/img/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>svgservlet</servlet-name>
<url-pattern>/svg/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>epsservlet</servlet-name>
<url-pattern>/eps/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>epstextservlet</servlet-name>
<url-pattern>/epstext/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>base64servlet</servlet-name>
<url-pattern>/base64/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>asciiservlet</servlet-name>
<url-pattern>/txt/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>checkservlet</servlet-name>
<url-pattern>/check/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>mapservlet</servlet-name>
<url-pattern>/map/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>plantumlservlet</servlet-name>
<url-pattern>/start/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>oldproxyservlet</servlet-name>
<url-pattern>/proxy/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>proxyservlet</servlet-name>
<url-pattern>/proxy</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>languageservlet</servlet-name>
<url-pattern>/language</url-pattern>
</servlet-mapping>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>
<welcome-file-list>
<welcome-file>welcome</welcome-file>
</welcome-file-list>
<web-app
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xmlns:web="https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
version="5.0"
>
<!-- ========================================================== -->
<!-- General -->
<!-- ========================================================== -->
<!-- Name the application -->
<display-name>PlantUML</display-name>
<description>PlantUML Online Server</description>
<!-- This app is cluster-ready -->
<distributable />
<!-- Set timeout to 120 minutes -->
<session-config>
<session-timeout>120</session-timeout>
</session-config>
<!-- ========================================================== -->
<!-- Custom Tag Libraries -->
<!-- ========================================================== -->
<!-- Taglib declarations are no longer required since JSP 2.0, see Removing taglib from web.xml -->
<!-- The <taglib> did not need to be a child of <jsp-config> in earlier versions but is required as of Tomcat 7 -->
<!-- Note that you can only have one <jsp-config> element per web.xml -->
<!--
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/lib/c.tld</taglib-location>
</taglib>
</jsp-config>
-->
<!-- ========================================================== -->
<!-- Context Parameters -->
<!-- ========================================================== -->
<context-param>
<param-name>org.eclipse.jetty.servlet.Default.welcomeServlets</param-name>
<param-value>exact</param-value>
</context-param>
<!-- ========================================================== -->
<!-- Servlets -->
<!-- ========================================================== -->
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.eclipse.jetty.jsp.JettyJspServlet</servlet-class>
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.7</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.7</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>plantumlservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.PlantUmlServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>plantumlservlet</servlet-name>
<url-pattern>/welcome</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>plantumlservlet</servlet-name>
<url-pattern>/uml/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>plantumlservlet</servlet-name>
<url-pattern>/form</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>plantumlservlet</servlet-name>
<url-pattern>/start/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>imgservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.ImgServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>imgservlet</servlet-name>
<url-pattern>/png/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>imgservlet</servlet-name>
<url-pattern>/img/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>svgservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.SvgServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>svgservlet</servlet-name>
<url-pattern>/svg/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>epsservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.EpsServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>epsservlet</servlet-name>
<url-pattern>/eps/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>epstextservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.EpsTextServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>epstextservlet</servlet-name>
<url-pattern>/epstext/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>base64servlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.Base64Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>base64servlet</servlet-name>
<url-pattern>/base64/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>asciiservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.AsciiServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>asciiservlet</servlet-name>
<url-pattern>/txt/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>proxyservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.ProxyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>proxyservlet</servlet-name>
<url-pattern>/proxy</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>oldproxyservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.OldProxyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>oldproxyservlet</servlet-name>
<url-pattern>/proxy/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>mapservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.MapServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>mapservlet</servlet-name>
<url-pattern>/map/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>checkservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.CheckSyntaxServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>checkservlet</servlet-name>
<url-pattern>/check/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>languageservlet</servlet-name>
<servlet-class>net.sourceforge.plantuml.servlet.LanguageServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>languageservlet</servlet-name>
<url-pattern>/language</url-pattern>
</servlet-mapping>
<!-- ========================================================== -->
<!-- Error Handler -->
<!-- ========================================================== -->
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>
<!-- ========================================================== -->
<!-- Welcome Files -->
<!-- ========================================================== -->
<welcome-file-list>
<welcome-file>welcome</welcome-file>
</welcome-file-list>
</web-app>

View File

@@ -1,12 +1,21 @@
<%@ page isErrorPage="true" contentType="text/html; charset=utf-8" pageEncoding="utf-8" session="false" %>
<c:set var="contextroot" value="${pageContext.request.contextPath}" />
<c:if test="${(pageContext.request.scheme == 'http' && pageContext.request.serverPort != 80) ||
(pageContext.request.scheme == 'https' && pageContext.request.serverPort != 443) }">
<c:set var="port" value=":${pageContext.request.serverPort}" />
</c:if>
<c:set var="scheme" value="${(not empty header['x-forwarded-proto']) ? header['x-forwarded-proto'] : pageContext.request.scheme}" />
<c:set var="hostpath" value="${scheme}://${pageContext.request.serverName}${port}${contextroot}" />
<%
String contextroot = request.getContextPath();
String port = "";
if (
(request.getScheme() == "http" && request.getServerPort() != 80)
||
(request.getScheme() == "https" && request.getServerPort() != 443)
) {
port = ":" + request.getServerPort();
}
String scheme = request.getScheme();
if (request.getHeader("x-forwarded-proto") != null && request.getHeader("x-forwarded-proto") != "") {
scheme = request.getHeader("x-forwarded-proto");
}
String hostpath = scheme + "://" + request.getServerName() + port + contextroot;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
@@ -15,23 +24,23 @@
<meta http-equiv="expires" content="0" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache, must-revalidate" />
<link rel="stylesheet" href="${hostpath}/plantuml.css" type="text/css"/>
<link rel="icon" href="${hostpath}/favicon.ico" type="image/x-icon"/>
<link rel="shortcut icon" href="${hostpath}/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="<%= hostpath %>/plantuml.css" type="text/css"/>
<link rel="icon" href="<%= hostpath %>/favicon.ico" type="image/x-icon"/>
<link rel="shortcut icon" href="<%= hostpath %>/favicon.ico" type="image/x-icon"/>
<title>PlantUMLServer Error</title>
</head>
<body>
<p>
Sorry, but things didn't work out as planned.
</p>
<hr/>
<jsp:useBean id="now" class="java.util.Date" />
<ul>
<li><%=now.toString() %></li>
<li>Request that failed: <%=pageContext.getErrorData().getRequestURI() %></li>
<li>Status code: <%=pageContext.getErrorData().getStatusCode() %></li>
<li>Exception: <%=pageContext.getErrorData().getThrowable() %></li>
</ul>
<hr/>
<p>
Sorry, but things didn't work out as planned.
</p>
<hr/>
<jsp:useBean id="now" class="java.util.Date" />
<ul>
<li><%= now.toString() %></li>
<li>Request that failed: <%= pageContext.getErrorData().getRequestURI() %></li>
<li>Status code: <%= pageContext.getErrorData().getStatusCode() %></li>
<li>Exception: <%= pageContext.getErrorData().getThrowable() %></li>
</ul>
<hr/>
</body>
</html>
</html>

View File

@@ -1,5 +1,4 @@
<div id="footer">
<p>PlantUML Server ${timestamp} / version <%= net.sourceforge.plantuml.version.Version.version() %>
</p>
</div>
<p>PlantUML Server Version <%= net.sourceforge.plantuml.version.Version.version() %>
</p>
</div>

View File

@@ -1,22 +1,24 @@
<%@ page info="index" contentType="text/html; charset=utf-8" pageEncoding="utf-8" session="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="cfg" value="${applicationScope['cfg']}" />
<c:set var="contextroot" value="${pageContext.request.contextPath}" />
<c:if test="${(pageContext.request.scheme == 'http' && pageContext.request.serverPort != 80) ||
(pageContext.request.scheme == 'https' && pageContext.request.serverPort != 443) }">
<c:set var="port" value=":${pageContext.request.serverPort}" />
</c:if>
<c:set var="scheme" value="${(not empty header['x-forwarded-proto']) ? header['x-forwarded-proto'] : pageContext.request.scheme}" />
<c:set var="hostpath" value="${scheme}://${pageContext.request.serverName}${port}${contextroot}" />
<c:if test="${!empty encoded}">
<c:set var="imgurl" value="${hostpath}/png/${encoded}" />
<c:set var="svgurl" value="${hostpath}/svg/${encoded}" />
<c:set var="txturl" value="${hostpath}/txt/${encoded}" />
<c:if test="${!empty mapneeded}">
<c:set var="mapurl" value="${hostpath}/map/${encoded}" />
</c:if>
</c:if>
<%
// diagram sources
String decoded = request.getAttribute("decoded").toString();
String encoded = request.getAttribute("encoded").toString();
// properties
boolean showSocialButtons = (boolean)request.getAttribute("showSocialButtons");
boolean showGithubRibbon = (boolean)request.getAttribute("showGithubRibbon");
// URL base
String hostpath = request.getAttribute("hostpath").toString();
// image URLs
boolean hasImg = (boolean)request.getAttribute("hasImg");
String imgurl = request.getAttribute("imgurl").toString();
String svgurl = request.getAttribute("svgurl").toString();
String txturl = request.getAttribute("txturl").toString();
String mapurl = request.getAttribute("mapurl").toString();
// map for diagram source if necessary
boolean hasMap = (boolean)request.getAttribute("hasMap");
String map = request.getAttribute("map").toString();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
@@ -25,73 +27,67 @@
<meta http-equiv="expires" content="0" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache, must-revalidate" />
<link rel="icon" href="${hostpath}/favicon.ico" type="image/x-icon"/>
<link rel="shortcut icon" href="${hostpath}/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="${hostpath}/plantuml.css" />
<link rel="stylesheet" href="${hostpath}/webjars/codemirror/5.63.0/lib/codemirror.css" />
<script src="${hostpath}/webjars/codemirror/5.63.0/lib/codemirror.js"></script>
<link rel="icon" href="<%= hostpath %>/favicon.ico" type="image/x-icon"/>
<link rel="shortcut icon" href="<%= hostpath %>/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="<%= hostpath %>/plantuml.css" />
<link rel="stylesheet" href="<%= hostpath %>/webjars/codemirror/5.63.0/lib/codemirror.css" />
<script src="<%= hostpath %>/webjars/codemirror/5.63.0/lib/codemirror.js"></script>
<script>
window.onload = function() {
document.myCodeMirror = CodeMirror.fromTextArea(
document.getElementById("text"),
{lineNumbers: true}
{ lineNumbers: true }
);
};
</script>
<title>PlantUMLServer</title>
</head>
<body>
<div id="header">
<%-- PAGE TITLE --%>
<h1>PlantUML Server</h1>
<c:if test="${cfg['SHOW_SOCIAL_BUTTONS'] eq 'on' }">
<%@ include file="resource/socialbuttons1.html" %>
</c:if>
<c:if test="${cfg['SHOW_GITHUB_RIBBON'] eq 'on' }">
<%@ include file="resource/githubribbon.html" %>
</c:if>
<p>Create your <a href="https://plantuml.com">PlantUML</a> diagrams directly in your browser !</p>
</div>
<div id="content">
<%-- CONTENT --%>
<form method="post" accept-charset="UTF-8" action="${contextroot}/form">
<p>
<textarea id="text" name="text" cols="120" rows="10"><c:out value="${decoded}"/></textarea>
<input type="submit" />
</p>
</form>
<hr/>
<p>You can enter here a previously generated URL:</p>
<form method="post" action="${contextroot}/form">
<p>
<input name="url" type="text" size="150" value="${imgurl}" />
<br/>
<input type="submit"/>
</p>
</form>
<c:if test="${!empty imgurl}">
<div id="header">
<%-- PAGE TITLE --%>
<h1>PlantUML Server</h1>
<% if (showSocialButtons) { %>
<%@ include file="resource/socialbuttons1.html" %>
<% } %>
<% if (showGithubRibbon) { %>
<%@ include file="resource/githubribbon.html" %>
<% } %>
<p>Create your <a href="https://plantuml.com">PlantUML</a> diagrams directly in your browser!</p>
</div>
<div id="content">
<%-- CONTENT --%>
<form method="post" accept-charset="utf-8" action="<%= hostpath %>/form">
<p>
<textarea id="text" name="text" cols="120" rows="10"><%= decoded %></textarea>
<input type="submit" />
</p>
</form>
<hr/>
<a href="${svgurl}">View as SVG</a>&nbsp;
<a href="${txturl}">View as ASCII Art</a>&nbsp;
<c:if test="${!empty mapurl}">
<a href="${mapurl}">View Map Data</a>
</c:if>
<c:if test="${cfg['SHOW_SOCIAL_BUTTONS'] == 'on' }">
<%@ include file="resource/socialbuttons2.jspf" %>
</c:if>
<p id="diagram">
<c:choose>
<c:when test="${!empty mapurl}">
<img src="${imgurl}" alt="PlantUML diagram" />
</c:when>
<c:otherwise>
<img src="${imgurl}" alt="PlantUML diagram" />
</c:otherwise>
</c:choose>
</p>
</c:if>
</div>
<%-- FOOTER --%>
<%@ include file="footer.jspf" %>
<p>You can enter here a previously generated URL:</p>
<form method="post" action="<%= hostpath %>/form">
<p>
<input name="url" type="text" size="150" value="<%= imgurl %>" />
<br/>
<input type="submit"/>
</p>
</form>
<% if (hasImg) { %>
<hr/>
<a href="<%= svgurl %>">View as SVG</a>&nbsp;
<a href="<%= txturl %>">View as ASCII Art</a>&nbsp;
<% if (hasMap) { %>
<a href="<%= mapurl %>">View Map Data</a>
<% } %>
<% if (showSocialButtons) { %>
<%@ include file="resource/socialbuttons2.jspf" %>
<% } %>
<p id="diagram">
<img src="<%= imgurl %>" alt="PlantUML diagram" />
<%= map %>
</p>
<% } %>
</div>
<%-- FOOTER --%>
<%@ include file="footer.jspf" %>
</body>
</html>