1 7 8 package com.lutris.appserver.debugger.presentation; 9 10 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 import com.lutris.appserver.debugger.spec.*; 17 import org.w3c.dom.*; 18 import org.w3c.dom.html.*; 19 20 import java.io.IOException ; 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 { 30 31 String host=null; 32 String num=null; 33 String sheme=null; 34 35 try { 36 host = comms.request.getServerName(); 37 } catch (Exception e) { 38 host=Debugger.host; 39 } 40 41 try { 42 num = new Integer (comms.request.getServerPort()).toString(); 43 } catch (Exception e) { 44 num=Debugger.num; 45 } 46 47 try { 48 sheme = comms.request.getScheme(); 49 } catch (Exception 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 [] elements = sm.getServletNames(); 78 79 80 if(elements.length != 0) 81 { 82 for(int i = 0; i < elements.length; i++) 83 { 84 String 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 |