(10)--webapp

Source: Internet
Author: User

Tags: production gets equal else except conf CEP WebApp ALAC

1  PackageMy.tomcat2;2 3 Importorg.xml.sax.SAXException;4 5 Importjavax.xml.parsers.ParserConfigurationException;6 ImportJavax.xml.parsers.SAXParser;7 Importjavax.xml.parsers.SAXParserFactory;8 Importjava.io.IOException;9 Importjava.util.List;Ten ImportJava.util.Map; One  A  Public classWebApp { -     Private StaticServletContext ServletContext; -  the     Static { -         Try { -             //Create a resolution factory -SAXParserFactory saxparserfactory =saxparserfactory.newinstance (); +             //produce a parser -SAXParser SAXParser =Saxparserfactory.newsaxparser (); +             //get a document processor AWebHandler WebHandler =NewWebHandler (); at             //which file needs to be parsed and what document processor to use for processing -Saxparser.parse (Thread.CurrentThread (). Getcontextclassloader (). getResourceAsStream ("Web. xml"), WebHandler); -              -             //There's no need for us to manually store the information in a map . -             //Save the Entitys in WebHandler to the servlet -ServletContext =NewServletContext (); inmap<string, string> servlet =Servletcontext.getservlet (); -              for(Entity temp:webHandler.getEntities ()) { to Servlet.put (Temp.getservletname (), Temp.getservletclass ()); +             } -             //Deposit The Mappings in the WebHandler into the mapping themap<string, string> mapping =servletcontext.getmapping (); *              for(Mapping temp:webHandler.getMappings ()) { $list<string> URLs =temp.geturllist ();Panax Notoginseng                  for(String str:urls) { - mapping.put (str, temp.getservletname ()); the                 } +             } A}Catch(saxexception e) { the e.printstacktrace (); +}Catch(IOException e) { - e.printstacktrace (); $}Catch(parserconfigurationexception e) { $ e.printstacktrace (); -         } -  the     } -     Wuyi     //The Servlet is fetched through a URL, which uses polymorphic, reflective the      Public StaticServlet getservlet (String URL)throwsclassnotfoundexception, Illegalaccessexception, instantiationexception { -         if(url = =NULL|| Url.trim (). Equals ("")) { Wu             return NULL; -}Else { AboutString reflect =Servletcontext.getservlet (). Get (Servletcontext.getmapping (). Get (URL)); $             return(Servlet) class.forname (reflect). Newinstance (); -         } -     } -}

(10)--webapp

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: