KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > appserver > debugger > presentation > Intro


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

7
8 package com.lutris.appserver.debugger.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
15 // Enhydra SuperServlet specification imports
16
import com.lutris.appserver.debugger.spec.*;
17 import org.w3c.dom.*;
18 import org.w3c.dom.html.*;
19
20 // Standard imports
21
import java.io.IOException JavaDoc;
22
23 import com.lutris.appserver.debugger.Debugger;
24
25 public class Intro implements HttpPresentation {
26
27
28     public void run(HttpPresentationComms comms)
29         throws HttpPresentationException, IOException JavaDoc {
30             
31             String JavaDoc host=null;
32       String JavaDoc num=null;
33       String JavaDoc sheme=null;
34       
35             try {
36           host = comms.request.getServerName();
37         } catch (Exception JavaDoc e) {
38             host=Debugger.host;
39         }
40             
41             try {
42           num = new Integer JavaDoc(comms.request.getServerPort()).toString();
43         } catch (Exception JavaDoc e) {
44             num=Debugger.num;
45         }
46         
47         try {
48           sheme = comms.request.getScheme();
49         } catch (Exception JavaDoc e) {
50             sheme="http";
51         }
52             
53       boolean found=Debugger.found;
54       
55       if(!found){
56         WelcomeHTML eror = (WelcomeHTML)comms.xmlcFactory.create(WelcomeHTML.class);
57         eror.setTextHost(host);
58          comms.response.writeHTML(eror);
59         }else{
60       
61       IntroHTML page = (IntroHTML)comms.xmlcFactory.create(IntroHTML.class);
62      
63        HTMLAnchorElement sampleAnchor= page.getElementList();
64        HTMLBRElement br = page.getElementBr();
65             
66        Node block = page.getElementBlock();
67        Node child = block.getFirstChild();
68        block.removeChild(child);
69        child = block.getFirstChild();
70        block.removeChild(child);
71
72      
73        page.setTextHost(host);
74      
75        ServletMonitor sm=ServletMonitorFactory.getServletMonitor("com.lutris.appserver.debugger.business.ServletMonitorImpl");
76       
77        String JavaDoc[] elements = sm.getServletNames();
78      
79       
80        if(elements.length != 0)
81         {
82             for(int i = 0; i < elements.length; i++)
83             {
84             String JavaDoc link = sheme+"://"+host+":"+num+elements[i];
85                 sampleAnchor.setHref(link);
86                 sampleAnchor.setTarget("_blank");
87                 page.setTextName(elements[i].substring(1));
88                 block.appendChild(sampleAnchor.cloneNode(true));
89                 block.appendChild(br.cloneNode(true));
90             }
91        }
92      
93          comms.response.writeHTML(page);
94 }
95   }
96 }
Popular Tags