mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 11:47:26 -08:00
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:
parent
69167c6bdc
commit
99e0f8d61b
|
@ -49,6 +49,7 @@ import java.net.MalformedURLException;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -56,7 +57,6 @@ import java.util.EnumMap;
|
|||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
@ -100,7 +100,6 @@ public final class DecodeServlet extends HttpServlet {
|
|||
Logger logger = Logger.getLogger("com.google.zxing");
|
||||
logger.addHandler(new ServletContextLogHandler(servletConfig.getServletContext()));
|
||||
diskFileItemFactory = new DiskFileItemFactory();
|
||||
log.info("DecodeServlet configured");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -343,10 +342,12 @@ public final class DecodeServlet extends HttpServlet {
|
|||
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.setCharacterEncoding("UTF8");
|
||||
Writer out = new OutputStreamWriter(response.getOutputStream(), "UTF8");
|
||||
Writer out = new OutputStreamWriter(response.getOutputStream(), Charset.forName("UTF-8"));
|
||||
try {
|
||||
for (Result result : results) {
|
||||
out.write(result.getText());
|
||||
|
@ -377,9 +378,4 @@ public final class DecodeServlet extends HttpServlet {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
log.config("DecodeServlet shutting down...");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,8 +14,10 @@
|
|||
See the License for the specific language governing permissions and
|
||||
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>
|
||||
<web-app version="3.0"
|
||||
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>
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!-- 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 session="false"/>
|
||||
<script type="text/javascript">
|
||||
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"));
|
||||
|
|
|
@ -14,21 +14,21 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!-- 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: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>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<jsp:text><![CDATA[<!DOCTYPE html>]]></jsp:text>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Bad Image</title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="main">
|
||||
<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
|
||||
image.
|
||||
</p>
|
||||
<p>The image you uploaded could not be decoded, or was too large. Go "Back" in your browser and try another image.</p>
|
||||
</div>
|
||||
<jsp:include page="analytics.jspx"/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -14,21 +14,21 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!-- 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: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>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<jsp:text><![CDATA[<!DOCTYPE html>]]></jsp:text>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Bad URL</title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="main">
|
||||
<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
|
||||
try again.
|
||||
</p>
|
||||
<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>
|
||||
</div>
|
||||
<jsp:include page="analytics.jspx"/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -14,39 +14,71 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!-- 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: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>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<jsp:text><![CDATA[<!DOCTYPE html>]]></jsp:text>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>ZXing Decoder Online</title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> ZXing Decoder Online</h1></div>
|
||||
<p>This is a simple page that will let you decode a 1D or 2D barcode found
|
||||
in an image online. Enter a URL below.
|
||||
</p>
|
||||
<form action="decode" method="get">
|
||||
<p>
|
||||
<input type="text" size="50" name="u"/>&nbsp;<input type="submit"/>
|
||||
<input type="hidden" name="full" value="true"/>
|
||||
</p>
|
||||
</form>
|
||||
<p>Or try uploading a file:</p>
|
||||
<form action="decode" method="post" enctype="multipart/form-data">
|
||||
<p>
|
||||
<input type="file" size="50" name="f"/>&nbsp;<input type="submit"/>
|
||||
<input type="hidden" name="full" value="true"/>
|
||||
</p>
|
||||
</form>
|
||||
<p>See the
|
||||
<a href="http://code.google.com/p/zxing">project page</a>
|
||||
for details.
|
||||
</p>
|
||||
<div id="footer"><p>Copyright 2008 and onwards ZXing authors</p></div>
|
||||
<div id="main">
|
||||
<div id="header">
|
||||
<h1><img src="zxing-icon.png" height="32" width="32" alt=""/> ZXing Decoder Online</h1>
|
||||
</div>
|
||||
<p>Decode a 1D or 2D barcode from an image on the web. Supported formats include:</p>
|
||||
<table><tr>
|
||||
<td><ul>
|
||||
<li>UPC-A and UPC-E</li>
|
||||
<li>EAN-8 and EAN-13</li>
|
||||
<li>Code 39</li>
|
||||
</ul></td>
|
||||
<td><ul>
|
||||
<li>Code 93</li>
|
||||
<li>Code 128</li>
|
||||
<li>ITF</li>
|
||||
</ul></td>
|
||||
<td><ul>
|
||||
<li>Codabar</li>
|
||||
<li>RSS-14 (all variants)</li>
|
||||
<li>RSS Expanded (most variants)</li>
|
||||
<li>QR Code</li>
|
||||
</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 (&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"/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -14,15 +14,14 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!-- 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 import="
|
||||
java.util.List,
|
||||
com.google.zxing.Result,
|
||||
com.google.zxing.client.result.ResultParser,
|
||||
com.google.zxing.client.result.ParsedResult,
|
||||
org.apache.commons.lang.StringEscapeUtils"/>
|
||||
<jsp:declaration>
|
||||
<jsp:declaration>
|
||||
private static String arrayToString(byte[] bytes) {
|
||||
int length = bytes.length;
|
||||
StringBuilder result = new StringBuilder(length << 2);
|
||||
|
@ -47,9 +46,10 @@
|
|||
</jsp:declaration>
|
||||
<jsp:directive.page contentType="text/html" session="false"/>
|
||||
<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>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<jsp:text><![CDATA[<!DOCTYPE html>]]></jsp:text>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Decode Succeeded</title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css"/>
|
||||
<style type="text/css">
|
||||
|
@ -57,6 +57,7 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="main">
|
||||
<div id="header"><h1><img src="zxing-icon.png" height="32" width="32" alt=""/> Decode Succeeded</h1></div>
|
||||
<jsp:scriptlet>
|
||||
for (Result result : (List<Result>) request.getAttribute("results")) {
|
||||
|
@ -112,7 +113,7 @@
|
|||
<jsp:scriptlet>
|
||||
}
|
||||
</jsp:scriptlet>
|
||||
<div id="footer"><p>Copyright 2008 and onwards ZXing authors</p></div>
|
||||
</div>
|
||||
<jsp:include page="analytics.jspx"/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -14,22 +14,24 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!-- 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: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>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<jsp:text><![CDATA[<!DOCTYPE html>]]></jsp:text>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>No Barcode Found</title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="main">
|
||||
<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
|
||||
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.
|
||||
</p>
|
||||
</div>
|
||||
<jsp:include page="analytics.jspx"/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -15,13 +15,14 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
<!-- Author: Sean Owen -->
|
||||
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
|
||||
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
||||
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.2">
|
||||
<jsp:directive.page contentType="text/html" session="false"/>
|
||||
<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>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<jsp:text><![CDATA[<!DOCTYPE html>]]></jsp:text>
|
||||
<html>
|
||||
<head>
|
||||
<title>Redirect</title>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta http-equiv="Refresh" content="0;url=decode.jspx"/>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -15,20 +15,22 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
<!-- 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: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>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<jsp:text><![CDATA[<!DOCTYPE html>]]></jsp:text>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>No Barcode Found</title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="main">
|
||||
<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
|
||||
supported format, or the software was simply unable to find it. Go "Back" in your browser and try another image.
|
||||
</p>
|
||||
supported format, or the software was simply unable to find it. Go "Back" in your browser and try another image.</p>
|
||||
</div>
|
||||
<jsp:include page="analytics.jspx"/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
body{background-color:#e9eef3;font-family:Arial,sans-serif;font-size:12px}
|
||||
td{font-size:14px}
|
||||
body {background-color:#e9eef3;margin:0;padding:0;padding-top:10px;text-align:center}
|
||||
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 h1{font-size:15px;font-weight:bold;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}
|
||||
#header h1{font-size:24px;padding:12px;border-bottom:1px solid #c8d0d9}
|
||||
|
|
Loading…
Reference in a new issue