⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 happyaxis.jsp

📁 开源的axis2框架的源码。用于开发WEBSERVER
💻 JSP
📖 第 1 页 / 共 2 页
字号:
        if (!resourceExists(resource)) {            out.write("<p><b>Warning</b>: could not find resource " + resource                    + "<br>"                    + errorText);            return 0;        } else {            out.write("found " + resource + "<br>");            return 1;        }    }    /**     *  get servlet version string     *     */    public String getServletVersion() {        ServletContext context = getServletConfig().getServletContext();        int major = context.getMajorVersion();        int minor = context.getMinorVersion();        return Integer.toString(major) + '.' + Integer.toString(minor);    }    /**     * what parser are we using.     * @return the classname of the parser     */    private String getParserName() {        SAXParser saxParser = getSAXParser();        if (saxParser == null) {            return "Could not create an XML Parser";        }        // check to what is in the classname        return saxParser.getClass().getName();    }    /**     * Create a JAXP SAXParser     * @return parser or null for trouble     */    private SAXParser getSAXParser() {        SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();        if (saxParserFactory == null) {            return null;        }        SAXParser saxParser = null;        try {            saxParser = saxParserFactory.newSAXParser();        } catch (Exception e) {        }        return saxParser;    }    /**     * get the location of the parser     * @return path or null for trouble in tracking it down     */    private String getParserLocation(JspWriter out) {        SAXParser saxParser = getSAXParser();        if (saxParser == null) {            return null;        }        return getLocation(out, saxParser.getClass());    }    private String value;    private OMElement createEnvelope() {        OMFactory fac = OMAbstractFactory.getOMFactory();        OMNamespace omNs = fac.createOMNamespace("http://axisversion.sample/xsd", "ns1");        OMElement method = fac.createOMElement("getVersion", omNs);        OMElement value = fac.createOMElement("myValue", omNs);        method.addChild(value);        return method;    }    public boolean invokeTheService() {        try {            // since this one is an internal request we do not use public frontendHostUrl            // for it            int lastindex = IP.lastIndexOf('/');            IP = IP.substring(0, lastindex);            ///axis2/axis2-web/services/version            IP = IP.replaceAll("axis2-web", "");            OMElement payload = createEnvelope();            ConfigurationContext configctx =                    ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);            ServiceClient client = new ServiceClient(configctx, null);            EndpointReference targetEPR = new EndpointReference(IP + configctx.getServicePath() + "/Version");            Options options = new Options();            client.setOptions(options);            options.setTo(targetEPR);            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);            OMElement result = client.sendReceive(payload);            StringWriter writer = new StringWriter();            result.serialize(XMLOutputFactory.newInstance().createXMLStreamWriter(writer));            writer.flush();            value = writer.toString();            return true;        } catch (AxisFault axisFault) {            System.out.println(value);            return false;        } catch (XMLStreamException e) {            value = e.getMessage();            return false;        }    }        public String getFormatedSystemProperty(String systemProperty){    	return  systemProperty.replaceAll(":", ": ");    }%><h1>Axis2 Happiness Page</h1><h2>Examining webapp configuration</h2><blockquote><h4>Essential Components</h4><%    int needed = 0,wanted = 0;    /**     * the essentials, without these Axis is not going to work     */    needed = needClass(out, "org.apache.axis2.transport.http.AxisServlet",            "axis2-1.0.jar",            "Apache-Axis",            "Axis2 will not work",            "http://xml.apache.org/axis2/");    needed += needClass(out, "org.apache.commons.logging.Log",            "commons-logging.jar",            "Jakarta-Commons Logging",            "Axis2 will not work",            "http://jakarta.apache.org/commons/logging.html");    needed += needClass(out, "javax.xml.stream.XMLStreamReader",            "stax-api-1.0.1.jar",            "Streaming API for XML",            "Axis2 will not work",            "http://dist.codehaus.org/stax/jars/");    needed += needClass(out, "org.codehaus.stax2.XMLStreamWriter2",            "wstx-asl-3.0.1.jar",            "Streaming API for XML implementation",            "Axis2 will not work",            "http://dist.codehaus.org/stax/jars/");%><%    /*    * resources on the classpath path    */    /* broken; this is a file, not a resource    wantResource(out,"/server-config.wsdd",    "There is no server configuration file;"    +"run AdminClient to create one");    */    /* add more libraries here */    //is everything we need here    if (needed == 0) {        //yes, be happy        out.write("<p><font color='green'><strong>The core axis2 libraries are present.</strong></font></p>");    } else {        //no, be very unhappy        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);        out.write("<font color='red'><i>"                + needed                + " core axis2 librar"                + (needed == 1 ? "y is" : "ies are")                + " missing</i></font>");    }    //now look at wanted stuff%><p>    <B><I>Note:</I></B> Even if everything this page probes for is present,    there is no guarantee your Axis Service will work, because there are many configuration options    that we do not check for. These tests are <i>necessary</i> but not <i>sufficient</i></p></blockquote><h2>Examining Version Service</h2><%    boolean serviceStatus = invokeTheService();    if (serviceStatus) {%><blockquote>    <font color="green"><strong>        Found Axis2 default Version service and Axis2 is working        properly.</strong></font>    <p>Now you can drop a service archive in axis2/WEB-INF/services.        Following output was produced while invoking Axis2 version service        </p>        <p><%= value%></p></blockquote><%} else {%><p>    <font color="brown"> There was a problem in Axis2 version service , may be        the service not available or some thing has gone wrong. But this does        not mean system is not working !        Try to upload some other service and check to see whether it is        working.        <br>    </font></p><%    }%><h2>Examining Application Server</h2><blockquote><table>    <tr><td>Servlet version</td><td><%=getServletVersion()%></td></tr>    <tr><td>Platform</td>        <td><%=getServletConfig().getServletContext().getServerInfo()%></td>    </tr></table></blockquote><h2>Examining System Properties</h2><%    /**     * Dump the system properties     */    java.util.Enumeration e = null;    try {        e = System.getProperties().propertyNames();    } catch (SecurityException se) {    }    if (e != null) {        out.write("<pre>");        out.write("<table cellpadding='5px' cellspacing='0px' style='border: .5px blue solid;'>");        for (; e.hasMoreElements();) {            out.write("<tr>");            String key = (String) e.nextElement();            out.write("<th style='border: .5px #A3BBFF solid;'>" + key + "</th>");            out.write("<td style='border: .5px #A3BBFF solid;'>" + getFormatedSystemProperty(System.getProperty(key)) + "&nbsp;</td>");            out.write("<tr>");        }        out.write("</table>");        out.write("</pre><p>");    } else {        out.write("System properties are not accessible<p>");    }%><jsp:include page="include/footer.inc"/></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -