JQTouch mobile app for user registration, tutorial

In the first article in this series I described a way to redirect iPhone clients to our mobile application. Now I will describe how to build a registration application using JQTouch.

A typical web application sends the content of each page, but in this model we deliver the whole application and only parts of the document are active at one time. To start, install JQTouch. I put it in js/ and css/ folders of the site. Then the JQTouch application needs a special header and container to refer to them. Notice I refer to an icon for the app which will appear if the user adds the web site to their home screen.

<!doctype html>
<meta charset=”UTF-8″ />
<title>Sneak on the Lot</title>
<style type=”text/css” media=”screen”>@import “js/jqtouch/jqtouch.min.css”;</style>
<style type=”text/css” media=”screen”>@import “css/themes/jqt/theme.min.css”;</style>
<script src=”js/jqtouch/jquery.1.3.2.min.js” type=”text/javascript” charset=”utf-8″></script>
<script src=”js/jqtouch/jqtouch.min.js” type=”application/x-javascript” charset=”utf-8″></script>

<script type=”text/javascript” charset=”utf-8″>
var jQT = new $.jQTouch({
icon: ‘images/icon.png’,
addGlossToIcon: false,
startupScreen: ‘images/splash.jpg’,
statusBar: ‘black’,
preloadImages: [



The landing page has a fullscreen background image with two buttons. Each one can be clicked to go to either the registration page or to a youtube video that talks about the site.

To make the links in the image work properly, they needed to be set up as <li> tags. We just need to remove the styling to make them invisible over the top of the background image. For simplicity, this styling is put in the header.

<style type=”text/css” media=”screen”>
#home {
background-image: url(images/main.jpg);
background-repeat: no-repeat;
a.splashlink {
position: absolute;
display: block;
padding: none;
margin: none;
text-shadow: none;
background-color: transparent;
border-bottom: none;
border-top: none;
.register {
width: 140px;
height: 40px;
top: 156px;
left: 89px;
.video {
width: 72px;
height: 63px;
top: 284px;
left: 17px;
ul.nostyle {
-webkit-background-clip: none;
background-image: none;
background-color: none;
color: none;
border-bottom-width: 0;
border-left-width: 0;
border-right-width: 0;
border-top-width: 0;
li.nostyle {
-webkit-background-clip: none;
background-image: none;
background-color: none;
color: none;
border-bottom-width: 0;
border-left-width: 0;
border-right-width: 0;
border-top-width: 0;

Next, the pages in the app are contained in divs and forms in the body.

<div id=”home”>
<li><a href=”#register”></a></li>
<li><a href=”http://www.youtube.com/watch?v=VXB4LqW6AYI” rel=”external”></a>
<form id=”register” action=”AppServlet” method=”POST”>
<a href=”#”>Back</a>
<a href=”#”>Sign up</a>
<li><input type=”text” name=”first_name” placeholder=”First Name” id=”some_name” /></li>
<li><input type=”text” name=”last_name” placeholder=”Last Name” id=”some_name” /></li>
<li><input type=”text” name=”email” placeholder=”Email” id=”some_name” autocapitalize=off /></li>
<li><input type=”text” name=”username” placeholder=”Username by which you’ll be known” id=”some_name” autocapitalize=off /></li>
<li><input type=”password” name=”password” placeholder=”password” id=”some_name” /></li>

What happens when the user submits the form? We make an ajax request to the action AppServlet on the server. In the case of a successful user create, it returns html like this:

<div id=”confirm”>
<h1>Thank you</h1>
<a href=”#home”>Home</a>
<center> Thank you for signing up!  <p>
You will receive an email soon with instructions on how to activate your account.  <p>
Please also check your Spam folder! </center>

In the case that it doesn’t work, we return a div with error messages that lets the user go back to the form.

<div id=”fail”>
<a href=”#register”>Try again</a>
<center> <div>Please try again.</div> </center>

In the next article I’ll talk about how to make these actions work in a java servlet inside jetty (specifically embedded in the smart fox server).

Try the app out in action by pointing an iPhone at sneakon.com or any webkit browser at sneakon.com/sneakapp