Debian Codegraph @

samples/jersey-ejb/src/main/webapp/index.html

raw
1 <!--
2
3 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
5 Copyright (c) 2010-2011 Oracle and/or its affiliates. All rights reserved.
6
7 The contents of this file are subject to the terms of either the GNU
8 General Public License Version 2 only ("GPL") or the Common Development
9 and Distribution License("CDDL") (collectively, the "License"). You
10 may not use this file except in compliance with the License. You can
11 obtain a copy of the License at
12 http://glassfish.java.net/public/CDDL+GPL_1_1.html
13 or packager/legal/LICENSE.txt. See the License for the specific
14 language governing permissions and limitations under the License.
15
16 When distributing the software, include this License Header Notice in each
17 file and include the License file at packager/legal/LICENSE.txt.
18
19 GPL Classpath Exception:
20 Oracle designates this particular file as subject to the "Classpath"
21 exception as provided by Oracle in the GPL Version 2 section of the License
22 file that accompanied this code.
23
24 Modifications:
25 If applicable, add the following below the License Header, with the fields
26 enclosed by brackets [] replaced by your own identifying information:
27 "Portions Copyright [year] [name of copyright owner]"
28
29 Contributor(s):
30 If you wish your version of this file to be governed by only the CDDL or
31 only the GPL Version 2, indicate your decision by adding "[Contributor]
32 elects to include this software in this distribution under the [CDDL or GPL
33 Version 2] license." If you don't indicate a single choice of license, a
34 recipient has the option to distribute your version of this file under
35 either the CDDL, the GPL Version 2 or to extend the choice of license to
36 its licensees as provided above. However, if you add GPL Version 2 code
37 and therefore, elected the GPL Version 2 license, then the option applies
38 only if the new code is made subject to such option by the copyright
39 holder.
40
41 -->
42 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
43 <html>
44 <head>
45 <title></title>
46 <meta http-equiv="Content-Type" content="text/html; charset=MacRoman">
47
48 <style>
49 .created {color: green}
50 .uniqueId {color: red}
51 .message {color: black}
52 </style>
53 </head>
54
55 <body>
56
57 <script type="text/javascript">
58 function getXmlHttpRequest() {
59 try
60 {
61 // Firefox, Opera 8.0+, Safari
62 return new XMLHttpRequest();
63 }
64 catch (e)
65 {
66 // Internet Explorer
67 try
68 {
69 return new ActiveXObject("Msxml2.XMLHTTP");
70 }
71 catch (e)
72 {
73 try
74 {
75 return new ActiveXObject("Microsoft.XMLHTTP");
76 }
77 catch (e)
78 {
79 alert("Your browser does not support AJAX!");
80 return null;
81 }
82 }
83 }
84 }
85
86 function getMessages()
87 {
88 var xmlHttp = getXmlHttpRequest();
89 xmlHttp.onreadystatechange=function()
90 {
91 if(xmlHttp.readyState==4)
92 {
93 document.getElementById("query").innerHTML="GET app/messages";
94 document.getElementById("output").innerHTML=xmlHttp.responseText;
95 }
96 }
97 xmlHttp.open("GET","app/messages/",true);
98 xmlHttp.send(null);
99 }
100
101
102 function getMessage(index)
103 {
104 var xmlHttp = getXmlHttpRequest();
105 xmlHttp.onreadystatechange=function()
106 {
107 if(xmlHttp.readyState==4)
108 {
109 document.getElementById("query").innerHTML="GET app/messages/" + index;
110 if(xmlHttp.responseText.indexOf("<body>") != -1) {
111 s = xmlHttp.responseText.substring(xmlHttp.responseText.indexOf("<body>") + 6, xmlHttp.responseText.indexOf("</body>"))
112 document.getElementById("output").innerHTML=s;
113 } else {
114 document.getElementById("output").innerHTML=xmlHttp.responseText;
115 }
116
117 }
118 }
119 xmlHttp.open("GET","app/messages/" + index,true);
120 xmlHttp.send(null);
121 }
122
123 function deleteMessage(index)
124 {
125 var xmlHttp = getXmlHttpRequest();
126 xmlHttp.onreadystatechange=function()
127 {
128 if(xmlHttp.readyState==4)
129 {
130 document.getElementById("query").innerHTML="DELETE app/messages/" + index;
131 if(xmlHttp.responseText.indexOf("<body>") != -1) {
132 s = xmlHttp.responseText.substring(xmlHttp.responseText.indexOf("<body>") + 6, xmlHttp.responseText.indexOf("</body>"))
133 document.getElementById("output").innerHTML=s;
134 } else {
135 document.getElementById("output").innerHTML=xmlHttp.responseText;
136 }
137 }
138 }
139 xmlHttp.open("DELETE","app/messages/" + index,true);
140 xmlHttp.send(null);
141 }
142
143 function addMessage(message)
144 {
145 var xmlHttp = getXmlHttpRequest();
146 xmlHttp.onreadystatechange=function()
147 {
148 if(xmlHttp.readyState==4)
149 {
150 document.getElementById("query").innerHTML="POST app/messages";
151 document.getElementById("output").innerHTML="";
152 }
153 }
154 xmlHttp.open("POST","app/messages/",true);
155 xmlHttp.send(message);
156 }
157
158
159 </script>
160
161
162 <h1>MessageBoard sample</h1>
163
164 <form name="form0">
165
166 <button type="button" name="GET0" onclick="getMessages()">LIST ALL MESSAGES</button>
167
168 </form>
169
170
171 <form name="form1">
172 Message id#: <input style="width: 4em" type="text" name="messageNumber" />
173
174 <button type="button" name="GET1" onclick="getMessage(document.form1.messageNumber.value)">GET MESSAGE</button>
175
176 </form>
177
178 <form name="form2">
179 Message id#: <input style="width: 4em" type="text" name="messageNumber" />
180
181 <button type="button" name="GET2" onclick="deleteMessage(document.form2.messageNumber.value)">DELETE MESSAGE</button>
182
183 </form>
184
185 <form name="form3">
186 Message: <input type="test" name="messageText" />
187
188 <button type="button" name="GET2" onclick="addMessage(document.form3.messageText.value)">ADD MESSAGE</button>
189
190 </form>
191
192
193 <h2>MessageBoard</h2>
194 <h3>query: </h3>
195 <div id="query" style="font-weight: bold"></div>
196 <h3>result</h3>
197 <div id="output" style="border: 1px solid black; color: black; height: 18em; width: 100%"></div>
198
199
200 <script type="text/javascript">
201 getMessages();
202 </script>
203
204
205 </body>
206 </html>