Minor touch ups of HTML, show full output for uploads, add more explanatory text and links, update to servlet 3 / JSP 2.2

git-svn-id: https://zxing.googlecode.com/svn/trunk@2540 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2012-11-28 22:12:37 +00:00
parent 69167c6bdc
commit 99e0f8d61b
11 changed files with 114 additions and 78 deletions

View file

@ -49,6 +49,7 @@ import java.net.MalformedURLException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -56,7 +57,6 @@ import java.util.EnumMap;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
@ -100,7 +100,6 @@ public final class DecodeServlet extends HttpServlet {
Logger logger = Logger.getLogger("com.google.zxing"); Logger logger = Logger.getLogger("com.google.zxing");
logger.addHandler(new ServletContextLogHandler(servletConfig.getServletContext())); logger.addHandler(new ServletContextLogHandler(servletConfig.getServletContext()));
diskFileItemFactory = new DiskFileItemFactory(); diskFileItemFactory = new DiskFileItemFactory();
log.info("DecodeServlet configured");
} }
@Override @Override
@ -343,10 +342,12 @@ public final class DecodeServlet extends HttpServlet {
return; return;
} }
if (request.getParameter("full") == null) { String fullParameter = request.getParameter("full");
boolean minimalOutput = fullParameter != null && !Boolean.parseBoolean(fullParameter);
if (minimalOutput) {
response.setContentType("text/plain"); response.setContentType("text/plain");
response.setCharacterEncoding("UTF8"); response.setCharacterEncoding("UTF8");
Writer out = new OutputStreamWriter(response.getOutputStream(), "UTF8"); Writer out = new OutputStreamWriter(response.getOutputStream(), Charset.forName("UTF-8"));
try { try {
for (Result result : results) { for (Result result : results) {
out.write(result.getText()); out.write(result.getText());
@ -377,9 +378,4 @@ public final class DecodeServlet extends HttpServlet {
} }
} }
@Override
public void destroy() {
log.config("DecodeServlet shutting down...");
}
} }

View file

@ -14,8 +14,10 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app version="3.0"
<web-app> 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_3_0.xsd">
<display-name>zxing.org</display-name> <display-name>zxing.org</display-name>

View file

@ -14,8 +14,8 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<!-- Author: Sean Owen --> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.2">
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2"> <jsp:directive.page session="false"/>
<script type="text/javascript"> <script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

View file

@ -14,21 +14,21 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<!-- Author: Sean Owen --> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.2">
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
<jsp:directive.page contentType="text/html" session="false"/> <jsp:directive.page contentType="text/html" session="false"/>
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet> <jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
<jsp:text><![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">]]></jsp:text> <jsp:text><![CDATA[<!DOCTYPE html>]]></jsp:text>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <html>
<head> <head>
<meta charset="UTF-8"/>
<title>Bad Image</title> <title>Bad Image</title>
<link rel="stylesheet" href="style.css" type="text/css"/> <link rel="stylesheet" href="style.css" type="text/css"/>
</head> </head>
<body> <body>
<div id="main">
<div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> Bad Image</h1></div> <div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> Bad Image</h1></div>
<p>The image you uploaded could not be decoded, or was too large. Go "Back" in your browser and try another <p>The image you uploaded could not be decoded, or was too large. Go "Back" in your browser and try another image.</p>
image. </div>
</p>
<jsp:include page="analytics.jspx"/> <jsp:include page="analytics.jspx"/>
</body> </body>
</html> </html>

View file

@ -14,21 +14,21 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<!-- Author: Sean Owen --> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.2">
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
<jsp:directive.page contentType="text/html" session="false"/> <jsp:directive.page contentType="text/html" session="false"/>
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet> <jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
<jsp:text><![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">]]></jsp:text> <jsp:text><![CDATA[<!DOCTYPE html>]]></jsp:text>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <html>
<head> <head>
<meta charset="UTF-8"/>
<title>Bad URL</title> <title>Bad URL</title>
<link rel="stylesheet" href="style.css" type="text/css"/> <link rel="stylesheet" href="style.css" type="text/css"/>
</head> </head>
<body> <body>
<div id="main">
<div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> Bad URL</h1></div> <div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> Bad URL</h1></div>
<p>You didn't specify a URL, or the URL was not valid, or did not return an image. Go "Back" in your browser and <p>You didn't specify a URL, or the URL was not valid, or did not return an image. Go "Back" in your browser and try again.</p>
try again. </div>
</p>
<jsp:include page="analytics.jspx"/> <jsp:include page="analytics.jspx"/>
</body> </body>
</html> </html>

View file

@ -14,39 +14,71 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<!-- Author: Sean Owen --> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.2">
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
<jsp:directive.page contentType="text/html" session="false"/> <jsp:directive.page contentType="text/html" session="false"/>
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet> <jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
<jsp:text><![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">]]></jsp:text> <jsp:text><![CDATA[<!DOCTYPE html>]]></jsp:text>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <html>
<head> <head>
<meta charset="UTF-8"/>
<title>ZXing Decoder Online</title> <title>ZXing Decoder Online</title>
<link rel="stylesheet" href="style.css" type="text/css"/> <link rel="stylesheet" href="style.css" type="text/css"/>
</head> </head>
<body> <body>
<div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> ZXing Decoder Online</h1></div> <div id="main">
<p>This is a simple page that will let you decode a 1D or 2D barcode found <div id="header">
in an image online. Enter a URL below. <h1><img src="zxing-icon.png" height="32" width="32" alt=""/> ZXing Decoder Online</h1>
</p> </div>
<form action="decode" method="get"> <p>Decode a 1D or 2D barcode from an image on the web. Supported formats include:</p>
<p> <table><tr>
<input type="text" size="50" name="u"/>&amp;nbsp;<input type="submit"/> <td><ul>
<input type="hidden" name="full" value="true"/> <li>UPC-A and UPC-E</li>
</p> <li>EAN-8 and EAN-13</li>
</form> <li>Code 39</li>
<p>Or try uploading a file:</p> </ul></td>
<form action="decode" method="post" enctype="multipart/form-data"> <td><ul>
<p> <li>Code 93</li>
<input type="file" size="50" name="f"/>&amp;nbsp;<input type="submit"/> <li>Code 128</li>
<input type="hidden" name="full" value="true"/> <li>ITF</li>
</p> </ul></td>
</form> <td><ul>
<p>See the <li>Codabar</li>
<a href="http://code.google.com/p/zxing">project page</a> <li>RSS-14 (all variants)</li>
for details. <li>RSS Expanded (most variants)</li>
</p> <li>QR Code</li>
<div id="footer"><p>Copyright 2008 and onwards ZXing authors</p></div> </ul></td>
<td><ul>
<li>Data Matrix</li>
<li>Aztec ('beta' quality)</li>
<li>PDF 417 ('alpha' quality)</li>
</ul></td>
</tr></table>
<table id="upload">
<form action="decode" method="get">
<tr>
<td style="text-align:right">Enter an image URL:</td>
<td><input type="text" size="80" name="u"/></td>
<td><input type="submit"/></td>
</tr>
</form>
<form action="decode" method="post" enctype="multipart/form-data">
<tr>
<td style="text-align:right">Or upload a file (&amp;lt;2MB):</td>
<td><input type="file" name="f"/></td>
<td><input type="submit"/></td>
</tr>
</form>
</table>
<p>This web application is powered by the barcode scanning implementation in the
open source <a href="http://code.google.com/p/zxing">ZXing</a> project.</p>
<p>Android users may download the
<a href="https://play.google.com/store/apps/details?id=com.google.zxing.client.android">Barcode Scanner</a> or
<a href="https://play.google.com/store/apps/details?id=com.srowen.bs.android">Barcode Scanner+</a> application
to access the same decoding as a mobile application.</p>
<p style="font-style:italic">Copyright 2008 and onwards ZXing authors</p>
</div>
<jsp:include page="analytics.jspx"/> <jsp:include page="analytics.jspx"/>
</body> </body>
</html> </html>

View file

@ -14,15 +14,14 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<!-- Author: Sean Owen --> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.2">
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
<jsp:directive.page import=" <jsp:directive.page import="
java.util.List, java.util.List,
com.google.zxing.Result, com.google.zxing.Result,
com.google.zxing.client.result.ResultParser, com.google.zxing.client.result.ResultParser,
com.google.zxing.client.result.ParsedResult, com.google.zxing.client.result.ParsedResult,
org.apache.commons.lang.StringEscapeUtils"/> org.apache.commons.lang.StringEscapeUtils"/>
<jsp:declaration> <jsp:declaration>
private static String arrayToString(byte[] bytes) { private static String arrayToString(byte[] bytes) {
int length = bytes.length; int length = bytes.length;
StringBuilder result = new StringBuilder(length &lt;&lt; 2); StringBuilder result = new StringBuilder(length &lt;&lt; 2);
@ -47,9 +46,10 @@
</jsp:declaration> </jsp:declaration>
<jsp:directive.page contentType="text/html" session="false"/> <jsp:directive.page contentType="text/html" session="false"/>
<jsp:scriptlet>response.setHeader("Cache-Control", "no-cache");</jsp:scriptlet> <jsp:scriptlet>response.setHeader("Cache-Control", "no-cache");</jsp:scriptlet>
<jsp:text><![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">]]></jsp:text> <jsp:text><![CDATA[<!DOCTYPE html>]]></jsp:text>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <html>
<head> <head>
<meta charset="UTF-8"/>
<title>Decode Succeeded</title> <title>Decode Succeeded</title>
<link rel="stylesheet" href="style.css" type="text/css"/> <link rel="stylesheet" href="style.css" type="text/css"/>
<style type="text/css"> <style type="text/css">
@ -57,6 +57,7 @@
</style> </style>
</head> </head>
<body> <body>
<div id="main">
<div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> Decode Succeeded</h1></div> <div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> Decode Succeeded</h1></div>
<jsp:scriptlet> <jsp:scriptlet>
for (Result result : (List&lt;Result&gt;) request.getAttribute("results")) { for (Result result : (List&lt;Result&gt;) request.getAttribute("results")) {
@ -112,7 +113,7 @@
<jsp:scriptlet> <jsp:scriptlet>
} }
</jsp:scriptlet> </jsp:scriptlet>
<div id="footer"><p>Copyright 2008 and onwards ZXing authors</p></div> </div>
<jsp:include page="analytics.jspx"/> <jsp:include page="analytics.jspx"/>
</body> </body>
</html> </html>

View file

@ -14,22 +14,24 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<!-- Author: Sean Owen --> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.2">
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
<jsp:directive.page contentType="text/html" session="false"/> <jsp:directive.page contentType="text/html" session="false"/>
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet> <jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
<jsp:text><![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">]]></jsp:text> <jsp:text><![CDATA[<!DOCTYPE html>]]></jsp:text>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <html>
<head> <head>
<meta charset="UTF-8"/>
<title>No Barcode Found</title> <title>No Barcode Found</title>
<link rel="stylesheet" href="style.css" type="text/css"/> <link rel="stylesheet" href="style.css" type="text/css"/>
</head> </head>
<body> <body>
<div id="main">
<div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> Barcode Format Problem</h1></div> <div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> Barcode Format Problem</h1></div>
<p>A barcode was possibly found in this image, but a problem occurred while decoding it. The data did not conform <p>A barcode was possibly found in this image, but a problem occurred while decoding it. The data did not conform
to the barcode format. This could be due to a misdetection of the barcode, or could indicate a problem to the barcode format. This could be due to a misdetection of the barcode, or could indicate a problem
with the barcode contents. Go "Back" in your browser and try another image. with the barcode contents. Go "Back" in your browser and try another image.
</p> </p>
</div>
<jsp:include page="analytics.jspx"/> <jsp:include page="analytics.jspx"/>
</body> </body>
</html> </html>

View file

@ -15,13 +15,14 @@
limitations under the License. limitations under the License.
--> -->
<!-- Author: Sean Owen --> <!-- Author: Sean Owen -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2"> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.2">
<jsp:directive.page contentType="application/xhtml+xml" session="false"/> <jsp:directive.page contentType="text/html" session="false"/>
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet> <jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
<jsp:text><![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">]]></jsp:text> <jsp:text><![CDATA[<!DOCTYPE html>]]></jsp:text>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <html>
<head> <head>
<title>Redirect</title> <title>Redirect</title>
<meta charset="UTF-8"/>
<meta http-equiv="Refresh" content="0;url=decode.jspx"/> <meta http-equiv="Refresh" content="0;url=decode.jspx"/>
</head> </head>
<body> <body>

View file

@ -15,20 +15,22 @@
limitations under the License. limitations under the License.
--> -->
<!-- Author: Sean Owen --> <!-- Author: Sean Owen -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2"> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.2">
<jsp:directive.page contentType="text/html" session="false"/> <jsp:directive.page contentType="text/html" session="false"/>
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet> <jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
<jsp:text><![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">]]></jsp:text> <jsp:text><![CDATA[<!DOCTYPE html>]]></jsp:text>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <html>
<head> <head>
<meta charset="UTF-8"/>
<title>No Barcode Found</title> <title>No Barcode Found</title>
<link rel="stylesheet" href="style.css" type="text/css"/> <link rel="stylesheet" href="style.css" type="text/css"/>
</head> </head>
<body> <body>
<div id="main">
<div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> No Barcode Found</h1></div> <div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> No Barcode Found</h1></div>
<p>No barcode was found in this image. Either it did not contain a barcode, or did not contain one in a <p>No barcode was found in this image. Either it did not contain a barcode, or did not contain one in a
supported format, or the software was simply unable to find it. Go "Back" in your browser and try another image. supported format, or the software was simply unable to find it. Go "Back" in your browser and try another image.</p>
</p> </div>
<jsp:include page="analytics.jspx"/> <jsp:include page="analytics.jspx"/>
</body> </body>
</html> </html>

View file

@ -1,7 +1,7 @@
body{background-color:#e9eef3;font-family:Arial,sans-serif;font-size:12px} body {background-color:#e9eef3;margin:0;padding:0;padding-top:10px;text-align:center}
td{font-size:14px} body,th,td,p{font-family:Arial,sans-serif}
div#main{width:800px;text-align:left;border:0;padding:0;margin:0 auto}
td{vertical-align:top}
table#upload td{padding:12px;height:30px;background-color:#dde3e9}
#header{background-color:#dde3e9;border-bottom:1px solid #f2f7fc} #header{background-color:#dde3e9;border-bottom:1px solid #f2f7fc}
#header h1{font-size:15px;font-weight:bold;padding:12px;border-bottom:1px solid #c8d0d9} #header h1{font-size:24px;padding:12px;border-bottom:1px solid #c8d0d9}
#header span{font-weight:normal;color:#5e6b75}
#footer{width:100%;text-align:center;padding-top:12px}
#footer a{text-decoration:none;color:#5e6b75}