1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
---|
2 | <html>
|
---|
3 | <head>
|
---|
4 | <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
|
---|
5 | <meta content="utf-8" http-equiv="encoding">
|
---|
6 | <title>User Log in</title>
|
---|
7 |
|
---|
8 | </head>
|
---|
9 | <body>
|
---|
10 | <center>
|
---|
11 | <fieldset style="width: 300px">
|
---|
12 | <legend> Register as new user </legend>
|
---|
13 | <table>
|
---|
14 | <tr>
|
---|
15 | <td>User name (required)</td>
|
---|
16 | <td><input type="text" id="name" name="username"
|
---|
17 | required="required" /></td>
|
---|
18 | </tr>
|
---|
19 | <tr>
|
---|
20 | <td>Password</td>
|
---|
21 | <td><input type="password" id="password" name="userpass" /></td>
|
---|
22 | </tr>
|
---|
23 | <tr>
|
---|
24 | <td>E-mail</td>
|
---|
25 | <td><input type="text" id="email" name="mail" " /></td>
|
---|
26 | </tr>
|
---|
27 | <tr>
|
---|
28 | <td><button onClick="register()">Register</button></td>
|
---|
29 | </tr>
|
---|
30 | </table>
|
---|
31 | <br> <b>Notice</b>: email is optional, but if you loose your
|
---|
32 | password your account will become unreachable.
|
---|
33 | </fieldset>
|
---|
34 |
|
---|
35 | </center>
|
---|
36 |
|
---|
37 |
|
---|
38 | <script>
|
---|
39 | "use strict";
|
---|
40 |
|
---|
41 | function register() {
|
---|
42 | var xmlHttp = new XMLHttpRequest();
|
---|
43 | xmlHttp.open("PUT", "AccountServlet", true); // false for synchronous request
|
---|
44 | xmlHttp.setRequestHeader('Content-Type', "text/json");
|
---|
45 | xmlHttp.onreadystatechange = function() {
|
---|
46 | if (xmlHttp.readyState == 4) {
|
---|
47 | if (xmlHttp.status == 200) {
|
---|
48 | alert("logged in!");
|
---|
49 | } else { // ugly stacktrace in html format
|
---|
50 | alert("register was rejected:...");
|
---|
51 | }
|
---|
52 | }
|
---|
53 | }
|
---|
54 | xmlHttp.send(JSON.stringify({
|
---|
55 | 'name' : document.getElementById('name').value,
|
---|
56 | 'password' : document.getElementById('password').value,
|
---|
57 | 'email' : document.getElementById('email').value
|
---|
58 | }));
|
---|
59 |
|
---|
60 | }
|
---|
61 | </script>
|
---|
62 |
|
---|
63 | <noscript>Sorry, your browser does not support JavaScript!</noscript>
|
---|
64 | </body>
|
---|
65 | </html>
|
---|