Skip to content

Commit

Permalink
Minor touch ups of HTML, show full output for uploads, add more expla…
Browse files Browse the repository at this point in the history
…natory text and links, update to servlet 3 / JSP 2.2

git-svn-id: http://zxing.googlecode.com/svn/trunk@2540 59b500cc-1b3d-0410-9834-0bbf25fbcc57
  • Loading branch information
srowen committed Nov 28, 2012
1 parent 29b4d52 commit ba9d7e4
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 78 deletions.
14 changes: 5 additions & 9 deletions zxingorg/src/com/google/zxing/web/DecodeServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
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;
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;
Expand Down Expand Up @@ -100,7 +100,6 @@ public void init(ServletConfig servletConfig) {
Logger logger = Logger.getLogger("com.google.zxing");
logger.addHandler(new ServletContextLogHandler(servletConfig.getServletContext()));
diskFileItemFactory = new DiskFileItemFactory();
log.info("DecodeServlet configured");
}

@Override
Expand Down Expand Up @@ -343,10 +342,12 @@ private static void processStream(InputStream is,
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());
Expand Down Expand Up @@ -377,9 +378,4 @@ private static void handleException(ReaderException re, HttpServletResponse resp
}
}

@Override
public void destroy() {
log.config("DecodeServlet shutting down...");
}

}
6 changes: 4 additions & 2 deletions zxingorg/web/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
4 changes: 2 additions & 2 deletions zxingorg/web/w/analytics.jspx
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
14 changes: 7 additions & 7 deletions zxingorg/web/w/badimage.jspx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
14 changes: 7 additions & 7 deletions zxingorg/web/w/badurl.jspx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
84 changes: 58 additions & 26 deletions zxingorg/web/w/decode.jspx
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>&amp;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"/>&amp;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 (&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"/>
</body>
</html>
Expand Down
13 changes: 7 additions & 6 deletions zxingorg/web/w/decoderesult.jspx
Original file line number Diff line number Diff line change
Expand Up @@ -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 &lt;&lt; 2);
Expand All @@ -47,16 +46,18 @@
</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">
td { vertical-align: top; padding: 0.1in; background-color: #EEEEEE; font-family: monospace; }
</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&lt;Result&gt;) request.getAttribute("results")) {
Expand Down Expand Up @@ -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>
Expand Down
10 changes: 6 additions & 4 deletions zxingorg/web/w/format.jspx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
9 changes: 5 additions & 4 deletions zxingorg/web/w/index.jspx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
12 changes: 7 additions & 5 deletions zxingorg/web/w/notfound.jspx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
12 changes: 6 additions & 6 deletions zxingorg/web/w/style.css
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit ba9d7e4

Please sign in to comment.