Skip to content

Commit

Permalink
Improve usability
Browse files Browse the repository at this point in the history
  • Loading branch information
k-tamura committed Feb 18, 2017
1 parent 08130b5 commit de0a9b9
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S
int days = -1;
int hours = -1;
PrintWriter writer = null;
String errorMessage = "";
try {
Locale locale = req.getLocale();
String strDays = req.getParameter("days");
Expand All @@ -39,14 +38,14 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S
if (days >= 0) {
// days * 24 => hours
hours = days * 24;
} else {
errorMessage = "<font color=\"red\">" + MessageUtils.getMsg("msg.enter.positive.number", locale)
+ "</font>";
}
}

StringBuilder bodyHtml = new StringBuilder();
bodyHtml.append("<form action=\"iof\" method=\"post\">");
bodyHtml.append(MessageUtils.getMsg("msg.enter.positive.number", locale));
bodyHtml.append("<br>");
bodyHtml.append("<br>");
if (days >= 0) {
bodyHtml.append("<input type=\"text\" name=\"days\" size=\"8\" maxlength=\"8\" value=" + strDays + ">");
} else {
Expand All @@ -60,7 +59,6 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S
bodyHtml.append("<br>");
bodyHtml.append("<input type=\"submit\" value=\"" + MessageUtils.getMsg("label.calculate", locale) + "\">");
bodyHtml.append("<br>");
bodyHtml.append(errorMessage);
bodyHtml.append("<br>");
bodyHtml.append(MessageUtils.getMsg("msg.note.positive.number",
new String[] { String.valueOf(Integer.MAX_VALUE / 24) }, locale));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S
PrintWriter writer = null;
double number = Double.NaN;
String strNumber = null;
String errorMessage = null;
boolean isValid = true;
try {
Locale locale = req.getLocale();
try {
Expand All @@ -38,28 +38,28 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S
// ignore
}
if (Double.isNaN(number) || number <= -1 || number == 0 || 1 <= number) {
errorMessage = MessageUtils.getMsg("msg.enter.decimal.value", locale);
isValid = false;
}

StringBuilder bodyHtml = new StringBuilder();
bodyHtml.append("<form action=\"lotd\" method=\"post\">");
if (!Double.isNaN(number) && errorMessage == null) {
bodyHtml.append(MessageUtils.getMsg("msg.enter.decimal.value", locale));
bodyHtml.append("<br>");
bodyHtml.append("<br>");
if (!Double.isNaN(number) && isValid) {
bodyHtml.append("<input type=\"text\" name=\"number\" size=\"18\" maxlength=\"18\" value=" + strNumber
+ ">");
} else {
bodyHtml.append("<input type=\"text\" name=\"number\" size=\"18\" maxlength=\"18\">");
}
bodyHtml.append(" + 1 = ");
if (!Double.isNaN(number) && errorMessage == null) {
if (!Double.isNaN(number) && isValid) {
bodyHtml.append(String.valueOf(number + 1));
}
bodyHtml.append("<br>");
bodyHtml.append("<br>");
bodyHtml.append("<input type=\"submit\" value=\"" + MessageUtils.getMsg("label.calculate", locale) + "\">");
bodyHtml.append("<br>");
if (errorMessage != null && strNumber != null) {
bodyHtml.append("<font color=\"red\">" + errorMessage + "</font>");
}
bodyHtml.append("<br>");
bodyHtml.append(MessageUtils.getMsg("msg.note.enter.decimal.value", locale));
bodyHtml.append("</form>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S
PrintWriter writer = null;
int number = -1;
double result = 0;
String errorMessage = "";
try {
Locale locale = req.getLocale();
String strNumber = req.getParameter("number");
Expand All @@ -38,14 +37,14 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S
}
if (1 <= number && number <= 9) {
result = number - 0.9;
} else {
errorMessage = "<font color=\"red\">" + MessageUtils.getMsg("msg.enter.positive.number", locale)
+ "</font>";
}
}

StringBuilder bodyHtml = new StringBuilder();
bodyHtml.append("<form action=\"roe\" method=\"post\">");
bodyHtml.append(MessageUtils.getMsg("msg.enter.positive.number", locale));
bodyHtml.append("<br>");
bodyHtml.append("<br>");
if (result != 0) {
bodyHtml.append("<input type=\"text\" name=\"number\" size=\"1\" maxlength=\"1\" value=" + strNumber
+ ">");
Expand All @@ -60,7 +59,6 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S
bodyHtml.append("<br>");
bodyHtml.append("<input type=\"submit\" value=\"" + MessageUtils.getMsg("label.calculate", locale) + "\">");
bodyHtml.append("<br>");
bodyHtml.append(errorMessage);
bodyHtml.append("<br>");
bodyHtml.append(MessageUtils.getMsg("msg.note.enter.one", locale));
bodyHtml.append("</form>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S
PrintWriter writer = null;
double number = -1;
double result = 0;
String errorMessage = "";
try {
Locale locale = req.getLocale();

Expand All @@ -39,18 +38,18 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S
}
if (0 < number && number < 10) {
result = 10.0 / number;
} else {
errorMessage = "<font color=\"red\">" + MessageUtils.getMsg("msg.enter.positive.number", locale)
+ "</font>";
}
}

StringBuilder bodyHtml = new StringBuilder();
bodyHtml.append("<form action=\"te\" method=\"post\">");
bodyHtml.append(MessageUtils.getMsg("msg.enter.positive.number", locale));
bodyHtml.append("<br>");
bodyHtml.append("<br>");
bodyHtml.append("10.0 " + MessageUtils.getMsg("label.obelus", locale) + " ");
if (result != 0) {
bodyHtml.append("<input type=\"text\" name=\"number\" size=\"1\" maxlength=\"1\" value=" + strNumber
+ ">");
bodyHtml.append(
"<input type=\"text\" name=\"number\" size=\"1\" maxlength=\"1\" value=" + strNumber + ">");
} else {
bodyHtml.append("<input type=\"text\" name=\"number\" size=\"1\" maxlength=\"1\">");
}
Expand All @@ -62,7 +61,6 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S
bodyHtml.append("<br>");
bodyHtml.append("<input type=\"submit\" value=\"" + MessageUtils.getMsg("label.calculate", locale) + "\">");
bodyHtml.append("<br>");
bodyHtml.append(errorMessage);
bodyHtml.append("<br>");
bodyHtml.append(MessageUtils.getMsg("msg.note.enter.specific.nembers", locale));
bodyHtml.append("</form>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S
Process process = pb.start();
process.waitFor();
bodyHtml.append(MessageUtils.getMsg("msg.executed.batch", locale) + batFile.getAbsolutePath()
+ "<BR><BR>");
+ "<BR><BR>");
bodyHtml.append(MessageUtils.getMsg("label.execution.result", locale) + "<BR><BR>");
bodyHtml.append(printInputStream(process.getInputStream(), res));
bodyHtml.append(printInputStream(process.getErrorStream(), res));
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ label.asc=asc
label.calculate=Calculate
label.character.count=Character Count
label.desc=desc
label.execution.result=Execution Result:
label.name=Name
label.multiplication.sign=*
label.obelus=/
Expand All @@ -22,7 +23,7 @@ msg.deadlock.occurs=A lock could not be obtained due to a deadlock.
msg.enter.name.and.passwd=If you enter your name and password, then your secret number is shown.
msg.enter.name=Please enter your name.
msg.enter.positive.number=Please enter a positive number.
msg.enter.decimal.value=Please enter a decimal value.
msg.enter.decimal.value=Please enter a decimal number less than 1.
msg.error.user.not.exist=User does not exist or password does not match.
msg.example.name.and.passwd=For example, Mark and password
msg.executed.batch=Created and executed the batch:
Expand Down
9 changes: 5 additions & 4 deletions src/main/resources/messages_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ label.asc=\u6607\u9806
label.calculate=\u8a08\u7b97\u3059\u308b
label.character.count=\u6587\u5b57\u6570
label.desc=\u964d\u9806
label.execution.result=\u5b9f\u884c\u7d50\u679c:
label.name=\u540d\u524d
label.multiplication.sign=×
label.obelus=÷
label.multiplication.sign=\u00d7
label.obelus=\u00f7
label.order=\u9806\u5e8f
label.password=\u30d1\u30b9\u30ef\u30fc\u30c9
label.reversed.name=\u9006\u8ee2\u3057\u305f\u540d\u524d
Expand All @@ -22,7 +23,7 @@ msg.deadlock.occurs=\u30c7\u30c3\u30c9\u30ed\u30c3\u30af\u306b\u3088\u308a\u30ed
msg.enter.name.and.passwd=\u540d\u524d\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5165\u529b\u3059\u308b\u3068\u3001\u6697\u8a3c\u756a\u53f7\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002
msg.enter.name=\u540d\u524d\u3092\u5165\u529b\u3057\u3066\u4e0b\u3055\u3044\u3002
msg.enter.positive.number=\u6b63\u306e\u6574\u6570\u3092\u5165\u529b\u3057\u3066\u4e0b\u3055\u3044\u3002
msg.enter.decimal.value=\u5c0f\u6570\u3092\u5165\u529b\u3057\u3066\u4e0b\u3055\u3044\u3002
msg.enter.decimal.value=1\u672a\u6e80\u306e\u5c0f\u6570\u3092\u5165\u529b\u3057\u3066\u4e0b\u3055\u3044\u3002
msg.error.user.not.exist=\u30e6\u30fc\u30b6\u30fc\u304c\u5b58\u5728\u3057\u306a\u3044\u304b\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u4e00\u81f4\u3057\u307e\u305b\u3093\u3002
msg.example.name.and.passwd=\u4f8b\u3048\u3070\u3001Mark \u3068 password
msg.executed.batch=\u30d0\u30c3\u30c1\u3092\u4f5c\u6210\u3001\u5b9f\u884c\u3057\u307e\u3057\u305f:
Expand All @@ -41,7 +42,7 @@ msg.note.enter.decimal.value=<span class="glyphicon glyphicon-info-sign"></span>
msg.note.positive.number=<span class="glyphicon glyphicon-info-sign"></span>&nbsp; \
{0}\u3088\u308a\u5927\u304d\u3044\u6570\u3092\u5165\u529b\u3059\u308b\u3068\u3001\u6574\u6570\u30aa\u30fc\u30d0\u30fc\u30d5\u30ed\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002
msg.note.sql.deadlock=<span class="glyphicon glyphicon-info-sign"></span>&nbsp; \
\u300c\u964d\u9806\u300d\u3092\u9078\u629e\u3057\u3066\u300c\u66f4\u65b0\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u76f4\u5f8c\u306b\u300c\u6607\u9806\u300d\u3092\u9078\u629e\u3057\u3001\
\u300c\u964d\u9806\u300d\u3092\u9078\u629e\u3057\u3066\u300c\u66f4\u65b0\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u76f4\u5f8c\u306b\u3001\u300c\u6607\u9806\u300d\u3092\u9078\u629e\u3057\u3066\
\u300c\u66f4\u65b0\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u30c7\u30c3\u30c9\u30ed\u30c3\u30af\u304c\u767a\u751f\u3057\u307e\u3059\u3002
msg.note.sql.injection=<span class="glyphicon glyphicon-info-sign"></span>&nbsp; \
\u30d1\u30b9\u30ef\u30fc\u30c9\u306b\u300c' OR '1'='1\u300d\u3092\u8a2d\u5b9a\u3059\u308b\u3068\u3001SQL\u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u304c\u767a\u751f\u3057\u307e\u3059\u3002
Expand Down

0 comments on commit de0a9b9

Please sign in to comment.