annotate client/digitallibrary/dlInfo-json.jsp @ 753:39bd5128811c jquery

first real JSON jsp: ImgInfo-json.jsp
author robcast
date Sat, 05 Feb 2011 22:50:15 +0100
parents client/digitallibrary/dlInfo-js.jsp@bc9196347188
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
78
e0dcac9c66fa New servlet version 1.5b.
robcast
parents:
diff changeset
1 <%@ page language="java" %>
e0dcac9c66fa New servlet version 1.5b.
robcast
parents:
diff changeset
2 <%!
e0dcac9c66fa New servlet version 1.5b.
robcast
parents:
diff changeset
3 // create DocumentBean instance for all JSP requests
e0dcac9c66fa New servlet version 1.5b.
robcast
parents:
diff changeset
4 digilib.servlet.DocumentBean docBean = new digilib.servlet.DocumentBean();
e0dcac9c66fa New servlet version 1.5b.
robcast
parents:
diff changeset
5
e0dcac9c66fa New servlet version 1.5b.
robcast
parents:
diff changeset
6 // initialize DocumentBean instance in JSP init
e0dcac9c66fa New servlet version 1.5b.
robcast
parents:
diff changeset
7 public void jspInit() {
e0dcac9c66fa New servlet version 1.5b.
robcast
parents:
diff changeset
8 try {
e0dcac9c66fa New servlet version 1.5b.
robcast
parents:
diff changeset
9 // set servlet init-parameter
e0dcac9c66fa New servlet version 1.5b.
robcast
parents:
diff changeset
10 docBean.setConfig(getServletConfig());
e0dcac9c66fa New servlet version 1.5b.
robcast
parents:
diff changeset
11 } catch (javax.servlet.ServletException e) {
e0dcac9c66fa New servlet version 1.5b.
robcast
parents:
diff changeset
12 System.out.println(e);
e0dcac9c66fa New servlet version 1.5b.
robcast
parents:
diff changeset
13 }
e0dcac9c66fa New servlet version 1.5b.
robcast
parents:
diff changeset
14 }
254
a6bd80bcd28b servlet version 1.19b5
robcast
parents: 218
diff changeset
15 %><%
a6bd80bcd28b servlet version 1.19b5
robcast
parents: 218
diff changeset
16 // parsing the query
78
e0dcac9c66fa New servlet version 1.5b.
robcast
parents:
diff changeset
17 digilib.servlet.DigilibRequest dlRequest = new digilib.servlet.DigilibRequest(request);
254
a6bd80bcd28b servlet version 1.19b5
robcast
parents: 218
diff changeset
18 docBean.setRequest(dlRequest);
78
e0dcac9c66fa New servlet version 1.5b.
robcast
parents:
diff changeset
19 %>
753
39bd5128811c first real JSON jsp: ImgInfo-json.jsp
robcast
parents: 548
diff changeset
20 // JSON format metadata about request and image
39bd5128811c first real JSON jsp: ImgInfo-json.jsp
robcast
parents: 548
diff changeset
21 {
254
a6bd80bcd28b servlet version 1.19b5
robcast
parents: 218
diff changeset
22 <%
548
bc9196347188 more refactoring and cleanup
robcast
parents: 254
diff changeset
23 Object[] keys = dlRequest.getParams().keySet().toArray();
254
a6bd80bcd28b servlet version 1.19b5
robcast
parents: 218
diff changeset
24 java.util.Arrays.sort(keys);
a6bd80bcd28b servlet version 1.19b5
robcast
parents: 218
diff changeset
25 int l = keys.length;
a6bd80bcd28b servlet version 1.19b5
robcast
parents: 218
diff changeset
26 for (int i = 0; i < l; i++) {
a6bd80bcd28b servlet version 1.19b5
robcast
parents: 218
diff changeset
27 String key = (String) keys[i];
a6bd80bcd28b servlet version 1.19b5
robcast
parents: 218
diff changeset
28 String val = dlRequest.getAsString(key);
a6bd80bcd28b servlet version 1.19b5
robcast
parents: 218
diff changeset
29 if (val.length() == 0) {
a6bd80bcd28b servlet version 1.19b5
robcast
parents: 218
diff changeset
30 val = "";
a6bd80bcd28b servlet version 1.19b5
robcast
parents: 218
diff changeset
31 }
753
39bd5128811c first real JSON jsp: ImgInfo-json.jsp
robcast
parents: 548
diff changeset
32 %>"<%= key %>" : "<%= val %>",
254
a6bd80bcd28b servlet version 1.19b5
robcast
parents: 218
diff changeset
33 <%
a6bd80bcd28b servlet version 1.19b5
robcast
parents: 218
diff changeset
34 }
a6bd80bcd28b servlet version 1.19b5
robcast
parents: 218
diff changeset
35 %>
753
39bd5128811c first real JSON jsp: ImgInfo-json.jsp
robcast
parents: 548
diff changeset
36 }