Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
runcon
Plantuml Server
Commits
dc7bc3e1
Commit
dc7bc3e1
authored
Oct 17, 2013
by
Maxime Sinclair
Browse files
[TASK] Scriptlet replaced by EL
parent
ccc71e7c
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/net/sourceforge/plantuml/servlet/PlantUmlServlet.java
View file @
dc7bc3e1
...
...
@@ -140,12 +140,12 @@ public class PlantUmlServlet extends HttpServlet {
encoded
=
transcoder
.
encode
(
text
);
}
request
.
setAttribute
(
"
net.sourceforge.plantuml.servlet.
decoded"
,
text
);
request
.
setAttribute
(
"
net.sourceforge.plantuml.servlet.
encoded"
,
encoded
);
request
.
setAttribute
(
"decoded"
,
text
);
request
.
setAttribute
(
"encoded"
,
encoded
);
// check if an image map is necessary
if
(
text
!=
null
&&
PlantumlUtils
.
hasCMapData
(
text
))
{
request
.
setAttribute
(
"
net.sourceforge.plantuml.servlet.
mapneeded"
,
Boolean
.
TRUE
);
request
.
setAttribute
(
"mapneeded"
,
Boolean
.
TRUE
);
}
// forward to index.jsp
...
...
src/main/java/net/sourceforge/plantuml/servlet/Welcome.java
View file @
dc7bc3e1
...
...
@@ -42,8 +42,8 @@ public class Welcome extends HttpServlet {
public
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
,
ServletException
{
// set the sample
request
.
setAttribute
(
"
net.sourceforge.plantuml.servlet.
decoded"
,
"Bob -> Alice : hello"
);
request
.
setAttribute
(
"
net.sourceforge.plantuml.servlet.
encoded"
,
"SyfFKj2rKt3CoKnELR1Io4ZDoSa70000"
);
request
.
setAttribute
(
"decoded"
,
"Bob -> Alice : hello"
);
request
.
setAttribute
(
"encoded"
,
"SyfFKj2rKt3CoKnELR1Io4ZDoSa70000"
);
// forward to index.jsp
RequestDispatcher
dispatcher
=
request
.
getRequestDispatcher
(
"/index.jsp"
);
...
...
src/main/webapp/index.jsp
View file @
dc7bc3e1
<%@ 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"
%>
<%
String
contextRoot
=
request
.
getContextPath
();
String
host
=
"http://"
+
request
.
getServerName
()
+
":"
+
request
.
getServerPort
();
String
encoded
=
""
;
String
umltext
=
""
;
String
imgurl
=
""
;
String
svgurl
=
""
;
String
txturl
=
""
;
Object
mapNeeded
=
request
.
getAttribute
(
"net.sourceforge.plantuml.servlet.mapneeded"
);
Object
encodedAttribute
=
request
.
getAttribute
(
"net.sourceforge.plantuml.servlet.encoded"
);
if
(
encodedAttribute
!=
null
)
{
encoded
=
encodedAttribute
.
toString
();
if
(!
encoded
.
isEmpty
())
{
imgurl
=
host
+
contextRoot
+
"/img/"
+
encoded
;
svgurl
=
host
+
contextRoot
+
"/svg/"
+
encoded
;
txturl
=
host
+
contextRoot
+
"/txt/"
+
encoded
;
if
(
mapNeeded
!=
null
)
{
pageContext
.
setAttribute
(
"mapurl"
,
host
+
contextRoot
+
"/map/"
+
encoded
);
}
}
}
Object
decodedAttribute
=
request
.
getAttribute
(
"net.sourceforge.plantuml.servlet.decoded"
);
if
(
decodedAttribute
!=
null
)
{
umltext
=
decodedAttribute
.
toString
();
}
%>
<c:set
var=
"contextroot"
value=
"
${
pageContext
.
request
.
contextPath
}
"
/>
<c:set
var=
"hostpath"
value=
"http://${pageContext.request.serverName}:${pageContext.request.serverPort}${contextroot}"
/>
<c:if
test=
"
${
!
empty
encoded
}
"
>
<c:set
var=
"imgurl"
value=
"
${
hostpath
}
/img/${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>
<!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"
>
...
...
@@ -34,9 +19,9 @@ if (decodedAttribute != null) {
<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=
"
<%=
context
R
oot
%>
/plantuml.css"
type=
"text/css"
/>
<link
rel=
"icon"
href=
"
<%=
context
R
oot
%>
/favicon.ico"
type=
"image/x-icon"
/>
<link
rel=
"shortcut icon"
href=
"
<%=
context
R
oot
%>
/favicon.ico"
type=
"image/x-icon"
/>
<link
rel=
"stylesheet"
href=
"
${
context
r
oot
}
/plantuml.css"
type=
"text/css"
/>
<link
rel=
"icon"
href=
"
${
context
r
oot
}
/favicon.ico"
type=
"image/x-icon"
/>
<link
rel=
"shortcut icon"
href=
"
${
context
r
oot
}
/favicon.ico"
type=
"image/x-icon"
/>
<title>
PlantUMLServer
</title>
</head>
<body>
...
...
@@ -47,40 +32,43 @@ if (decodedAttribute != null) {
</div>
<div
id=
"content"
>
<%-- CONTENT --%>
<form
method=
"post"
accept-charset=
"UTF-8"
action=
"
<%=
context
R
oot
%>
/form"
>
<form
method=
"post"
accept-charset=
"UTF-8"
action=
"
${
context
r
oot
}
/form"
>
<p>
<textarea
name=
"text"
cols=
"120"
rows=
"10"
><
%=
umltext
%
></textarea>
<textarea
name=
"text"
cols=
"120"
rows=
"10"
><
c:out
value=
"
${
decoded
}
"
/
></textarea>
<br/>
<input
type=
"submit"
/>
</p>
</form>
<hr/>
You can enter here a previously generated URL:
<form
method=
"post"
action=
"
<%=
context
R
oot
%>
/form"
>
<form
method=
"post"
action=
"
${
context
r
oot
}
/form"
>
<p>
<input
name=
"url"
type=
"text"
size=
"150"
value=
"
<%=
imgurl
%>
"
/>
<input
name=
"url"
type=
"text"
size=
"150"
value=
"
${
imgurl
}
"
/>
<br/>
<input
type=
"submit"
/>
</p>
</form>
<%
if
(!
imgurl
.
isEmpty
())
{
%>
<hr/>
<a
href=
"
<%=
svgurl
%>
"
>
View as SVG
</a>
<a
href=
"
<%=
txturl
%>
"
>
View as ASCII Art
</a>
<%
if
(
mapNeeded
!=
null
)
{
%>
<a
href=
"
<c:out
value=
"
${
mapurl
}
"
/>
"
>
View Map Data
</a>
<%
}
//endif
%>
<p
id=
"diagram"
>
<%
if
(
mapNeeded
!=
null
)
{
%>
<img
src=
"
<%=
imgurl
%>
"
alt=
"PlantUML diagram"
usemap=
"#umlmap"
/>
<map
name=
"umlmap"
>
<c:import
url=
"
${
mapurl
}
"
/>
</map>
<%
}
else
{
%>
<img
src=
"
<%=
imgurl
%>
"
alt=
"PlantUML diagram"
/>
<%
}
%>
</p>
<%
}
//endif
%>
<c:if
test=
"
${
!
empty
imgurl
}
"
>
<hr/>
<a
href=
"${svgurl}"
>
View as SVG
</a>
<a
href=
"${txturl}"
>
View as ASCII Art
</a>
<c:if
test=
"
${
!
empty
mapurl
}
"
>
<a
href=
"${mapurl}"
>
View Map Data
</a>
</c:if>
<p
id=
"diagram"
>
<c:choose>
<c:when
test=
"
${
!
empty
mapurl
}
"
>
<img
src=
"${imgurl}"
alt=
"PlantUML diagram"
usemap=
"#umlmap"
/>
<map
name=
"umlmap"
>
<c:import
url=
"
${
mapurl
}
"
/>
</map>
</c:when>
<c:otherwise>
<img
src=
"${imgurl}"
alt=
"PlantUML diagram"
/>
</c:otherwise>
</c:choose>
</p>
</c:if>
</div>
<!-- This comment is used by the TestProxy class
@startuml
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment