KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > snapper > presentation > Check


1 /*
2  * Ajax
3  *
4  * Enhydra super-servlet presentation object
5  *
6  */

7
8 package org.enhydra.snapper.presentation;
9
10 // Enhydra SuperServlet imports
11
import com.lutris.appserver.server.httpPresentation.HttpPresentation;
12 import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
13 import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
14 import com.lutris.appserver.server.sql.DBTransaction;
15
16 // Enhydra SuperServlet specification imports
17

18 // Standard imports
19
import java.io.IOException JavaDoc;
20
21 import org.enhydra.dods.DODS;
22 import org.enhydra.snapper.spec.Site;
23 import org.enhydra.snapper.spec.SiteList;
24 import org.enhydra.snapper.spec.SiteListFactory;
25
26 public class Check implements HttpPresentation {
27
28
29     public void run(HttpPresentationComms comms)
30         throws HttpPresentationException, IOException JavaDoc {
31         
32         
33         if (comms.request.getParameter("id") != null){
34         
35         DBTransaction dbTransaction = null;
36         SiteList sl;
37         
38         Site[] list;
39         try {
40             dbTransaction = DODS.getDatabaseManager().createTransaction();
41             sl = SiteListFactory.getSiteList("org.enhydra.snapper.business.SiteListImpl");
42             list = sl.getList(dbTransaction);
43             String JavaDoc target = comms.request.getParameter("id");
44             
45             for (int i = 0; i<list.length; i++){
46                 if (list[i].getName().equals(target)){
47                     dbTransaction.release();
48                     dbTransaction = null;
49                 comms.response.setContentType("text/xml");
50                 comms.response.setHeader("Cache-Control", "no-cache");
51                 comms.response.writeHTML("false");
52                 
53                 return;
54                 }
55             }
56                 dbTransaction.release();
57                 dbTransaction = null;
58                 comms.response.setContentType("text/xml");
59                 comms.response.setHeader("Cache-Control", "no-cache");
60                 comms.response.writeHTML("true");
61             
62         }catch (Exception JavaDoc ex){
63             System.out.println("Exception: "+ex);
64             list = null;
65             dbTransaction.release();
66             dbTransaction = null;
67             
68         }
69         
70                     
71         }
72     
73     
74     if (comms.request.getParameter("size") != null){
75         try{
76             Integer.parseInt(comms.request.getParameter("size"));
77             comms.response.setContentType("text/xml");
78             comms.response.setHeader("Cache-Control", "no-cache");
79             comms.response.writeHTML("true");
80         } catch (Exception JavaDoc e){
81             comms.response.setContentType("text/xml");
82             comms.response.setHeader("Cache-Control", "no-cache");
83             comms.response.writeHTML("false");
84         }
85             
86         }
87     
88     if (comms.request.getParameter("age") != null){
89         try{
90             Integer.parseInt(comms.request.getParameter("age"));
91             comms.response.setContentType("text/xml");
92             comms.response.setHeader("Cache-Control", "no-cache");
93             comms.response.writeHTML("true");
94         } catch (Exception JavaDoc e){
95             comms.response.setContentType("text/xml");
96             comms.response.setHeader("Cache-Control", "no-cache");
97             comms.response.writeHTML("false");
98         }
99             
100         }
101         
102     }
103         
104
105 }
106
Popular Tags