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

📄 __happyaxis.java

📁 《J2EE企业级应用开发》一书的配套源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* compiled from JSP: /happyaxis.jsp
*
* This code was automatically generated at 23:38:14 on 2001-4-14
* by weblogic.servlet.jsp.Jsp2Java -- do not edit.
*/

package jsp_servlet;

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

// User imports
import java.io.InputStream; //[ /happyaxis.jsp; Line: 10]import java.io.IOException; //[ /happyaxis.jsp; Line: 10]import javax.xml.parsers.SAXParser; //[ /happyaxis.jsp; Line: 10]import javax.xml.parsers.SAXParserFactory; //[ /happyaxis.jsp; Line: 10]

// built-in init parameters:
// boolean             _verbose -- wants debugging

// Well-known variables:
// JspWriter out                  -- to write to the browser
// HttpServletRequest  request    -- the request object.
// HttpServletResponse response   -- the response object.
// PageContext pageContext        -- the page context for this JSP
// HttpSession session            -- the session object for the client (if any)
// ServletContext application     -- The servlet (application) context
// ServletConfig config           -- The ServletConfig for this JSP
// Object page                    -- the instance of this page's implementation class (i.e., 'this')

/**
* This code was automatically generated at 23:38:14 on 2001-4-14
* by weblogic.servlet.jsp.Jsp2Java -- do not edit.
*
* Copyright (c) 2001 by BEA Systems, Inc. All Rights Reserved.
*/
public final class __happyaxis
extends
weblogic.servlet.jsp.JspBase
implements weblogic.servlet.jsp.StaleIndicator
{
    
    //[ /happyaxis.jsp; Line: 11]    //[ /happyaxis.jsp; Line: 12]    /* //[ /happyaxis.jsp; Line: 13]    * Happiness tests for axis. These look at the classpath and warn if things //[ /happyaxis.jsp; Line: 14]    * are missing. Normally addng this much code in a JSP page is mad //[ /happyaxis.jsp; Line: 15]    * but here we want to validate JSP compilation too, and have a drop-in //[ /happyaxis.jsp; Line: 16]    * page for easy re-use //[ /happyaxis.jsp; Line: 17]    * @author Steve 'configuration problems' Loughran //[ /happyaxis.jsp; Line: 18]    */ //[ /happyaxis.jsp; Line: 19]    //[ /happyaxis.jsp; Line: 20]    //[ /happyaxis.jsp; Line: 21]    /** //[ /happyaxis.jsp; Line: 22]    * Get a string providing install information. //[ /happyaxis.jsp; Line: 23]    * TODO: make this platform aware and give specific hints //[ /happyaxis.jsp; Line: 24]    */ //[ /happyaxis.jsp; Line: 25]    public String getInstallHints(HttpServletRequest request) { //[ /happyaxis.jsp; Line: 26]        //[ /happyaxis.jsp; Line: 27]        String hint= //[ /happyaxis.jsp; Line: 28]        "<B><I>Note:</I></B> On Tomcat 4.x, you may need to put libraries that contain " //[ /happyaxis.jsp; Line: 29]        +"java.* or javax.* packages into CATALINA_HOME/commons/lib"; //[ /happyaxis.jsp; Line: 30]        return hint; //[ /happyaxis.jsp; Line: 31]    } //[ /happyaxis.jsp; Line: 32]    //[ /happyaxis.jsp; Line: 33]    /** //[ /happyaxis.jsp; Line: 34]    * test for a class existing //[ /happyaxis.jsp; Line: 35]    * @param classname //[ /happyaxis.jsp; Line: 36]    * @return class iff present //[ /happyaxis.jsp; Line: 37]    */ //[ /happyaxis.jsp; Line: 38]    Class classExists(String classname) { //[ /happyaxis.jsp; Line: 39]        try { //[ /happyaxis.jsp; Line: 40]            return Class.forName(classname); //[ /happyaxis.jsp; Line: 41]        } catch (ClassNotFoundException e) { //[ /happyaxis.jsp; Line: 42]            return null; //[ /happyaxis.jsp; Line: 43]        } //[ /happyaxis.jsp; Line: 44]    } //[ /happyaxis.jsp; Line: 45]    //[ /happyaxis.jsp; Line: 46]    /** //[ /happyaxis.jsp; Line: 47]    * test for resource on the classpath //[ /happyaxis.jsp; Line: 48]    * @param resource //[ /happyaxis.jsp; Line: 49]    * @return true iff present //[ /happyaxis.jsp; Line: 50]    */ //[ /happyaxis.jsp; Line: 51]    boolean resourceExists(String resource) { //[ /happyaxis.jsp; Line: 52]        boolean found; //[ /happyaxis.jsp; Line: 53]        InputStream instream=this.getClass().getResourceAsStream(resource); //[ /happyaxis.jsp; Line: 54]        found=instream!=null; //[ /happyaxis.jsp; Line: 55]        if(instream!=null) { //[ /happyaxis.jsp; Line: 56]            try { //[ /happyaxis.jsp; Line: 57]                instream.close(); //[ /happyaxis.jsp; Line: 58]            } catch (IOException e) { //[ /happyaxis.jsp; Line: 59]            } //[ /happyaxis.jsp; Line: 60]        } //[ /happyaxis.jsp; Line: 61]        return found; //[ /happyaxis.jsp; Line: 62]    } //[ /happyaxis.jsp; Line: 63]    //[ /happyaxis.jsp; Line: 64]    /** //[ /happyaxis.jsp; Line: 65]    * probe for a class, print an error message is missing //[ /happyaxis.jsp; Line: 66]    * @param out stream to print stuff //[ /happyaxis.jsp; Line: 67]    * @param category text like "warning" or "error" //[ /happyaxis.jsp; Line: 68]    * @param classname class to look for //[ /happyaxis.jsp; Line: 69]    * @param jarFile where this class comes from //[ /happyaxis.jsp; Line: 70]    * @param errorText extra error text //[ /happyaxis.jsp; Line: 71]    * @param homePage where to d/l the library //[ /happyaxis.jsp; Line: 72]    * @return the number of missing classes //[ /happyaxis.jsp; Line: 73]    * @throws IOException //[ /happyaxis.jsp; Line: 74]    */ //[ /happyaxis.jsp; Line: 75]    int probeClass(JspWriter out, //[ /happyaxis.jsp; Line: 76]    String category, //[ /happyaxis.jsp; Line: 77]    String classname, //[ /happyaxis.jsp; Line: 78]    String jarFile, //[ /happyaxis.jsp; Line: 79]    String description, //[ /happyaxis.jsp; Line: 80]    String errorText, //[ /happyaxis.jsp; Line: 81]    String homePage) throws IOException { //[ /happyaxis.jsp; Line: 82]        //[ /happyaxis.jsp; Line: 83]        Class clazz = classExists(classname); //[ /happyaxis.jsp; Line: 84]        if(clazz == null)  { //[ /happyaxis.jsp; Line: 85]            String url=""; //[ /happyaxis.jsp; Line: 86]            if(homePage!=null) { //[ /happyaxis.jsp; Line: 87]                url="<br>  See <a href="+homePage+">"+homePage+"</a>"; //[ /happyaxis.jsp; Line: 88]            } //[ /happyaxis.jsp; Line: 89]            out.write("<p>"+category+": could not find class "+classname //[ /happyaxis.jsp; Line: 90]            +" from file <b>"+jarFile //[ /happyaxis.jsp; Line: 91]            +"</b><br>  "+errorText //[ /happyaxis.jsp; Line: 92]            +url //[ /happyaxis.jsp; Line: 93]            +"<p>"); //[ /happyaxis.jsp; Line: 94]            return 1; //[ /happyaxis.jsp; Line: 95]        } else { //[ /happyaxis.jsp; Line: 96]            String location = getLocation(out, clazz); //[ /happyaxis.jsp; Line: 97]            if(location == null) { //[ /happyaxis.jsp; Line: 98]                out.write("Found "+ description + " (" + classname + ")<br>"); //[ /happyaxis.jsp; Line: 99]            } //[ /happyaxis.jsp; Line: 100]            else { //[ /happyaxis.jsp; Line: 101]                out.write("Found "+ description + " (" + classname + ") at " + location + "<br>"); //[ /happyaxis.jsp; Line: 102]            } //[ /happyaxis.jsp; Line: 103]            return 0; //[ /happyaxis.jsp; Line: 104]        } //[ /happyaxis.jsp; Line: 105]    } //[ /happyaxis.jsp; Line: 106]    //[ /happyaxis.jsp; Line: 107]    /** //[ /happyaxis.jsp; Line: 108]    * get the location of a class //[ /happyaxis.jsp; Line: 109]    * @param out //[ /happyaxis.jsp; Line: 110]    * @param clazz //[ /happyaxis.jsp; Line: 111]    * @return the jar file or path where a class was found //[ /happyaxis.jsp; Line: 112]    * @throws IOException //[ /happyaxis.jsp; Line: 113]    */ //[ /happyaxis.jsp; Line: 114]    //[ /happyaxis.jsp; Line: 115]    String getLocation(JspWriter out, //[ /happyaxis.jsp; Line: 116]    Class clazz) throws IOException { //[ /happyaxis.jsp; Line: 117]        try { //[ /happyaxis.jsp; Line: 118]            java.net.URL url = clazz.getProtectionDomain().getCodeSource().getLocation(); //[ /happyaxis.jsp; Line: 119]            String location = url.toString(); //[ /happyaxis.jsp; Line: 120]            if(location.startsWith("jar")) { //[ /happyaxis.jsp; Line: 121]                url = ((java.net.JarURLConnection)url.openConnection()).getJarFileURL(); //[ /happyaxis.jsp; Line: 122]                location = url.toString(); //[ /happyaxis.jsp; Line: 123]            }  //[ /happyaxis.jsp; Line: 124]            //[ /happyaxis.jsp; Line: 125]            if(location.startsWith("file")) { //[ /happyaxis.jsp; Line: 126]                java.io.File file = new java.io.File(url.getFile()); //[ /happyaxis.jsp; Line: 127]                return file.getAbsolutePath(); //[ /happyaxis.jsp; Line: 128]            } else { //[ /happyaxis.jsp; Line: 129]                return url.toString(); //[ /happyaxis.jsp; Line: 130]            } //[ /happyaxis.jsp; Line: 131]        } catch (Throwable t){ //[ /happyaxis.jsp; Line: 132]        } //[ /happyaxis.jsp; Line: 133]        return null; //[ /happyaxis.jsp; Line: 134]    } //[ /happyaxis.jsp; Line: 135]    //[ /happyaxis.jsp; Line: 136]    /** //[ /happyaxis.jsp; Line: 137]    * a class we need if a class is missing //[ /happyaxis.jsp; Line: 138]    * @param out stream to print stuff //[ /happyaxis.jsp; Line: 139]    * @param classname class to look for //[ /happyaxis.jsp; Line: 140]    * @param jarFile where this class comes from //[ /happyaxis.jsp; Line: 141]    * @param errorText extra error text //[ /happyaxis.jsp; Line: 142]    * @param homePage where to d/l the library //[ /happyaxis.jsp; Line: 143]    * @throws IOException when needed //[ /happyaxis.jsp; Line: 144]    * @return the number of missing libraries (0 or 1) //[ /happyaxis.jsp; Line: 145]    */ //[ /happyaxis.jsp; Line: 146]    int needClass(JspWriter out, //[ /happyaxis.jsp; Line: 147]    String classname, //[ /happyaxis.jsp; Line: 148]    String jarFile, //[ /happyaxis.jsp; Line: 149]    String description, //[ /happyaxis.jsp; Line: 150]    String errorText, //[ /happyaxis.jsp; Line: 151]    String homePage) throws IOException { //[ /happyaxis.jsp; Line: 152]        return probeClass(out, //[ /happyaxis.jsp; Line: 153]        "<b>Error</b>", //[ /happyaxis.jsp; Line: 154]        classname, //[ /happyaxis.jsp; Line: 155]        jarFile, //[ /happyaxis.jsp; Line: 156]        description, //[ /happyaxis.jsp; Line: 157]        errorText, //[ /happyaxis.jsp; Line: 158]        homePage); //[ /happyaxis.jsp; Line: 159]    } //[ /happyaxis.jsp; Line: 160]    //[ /happyaxis.jsp; Line: 161]    /** //[ /happyaxis.jsp; Line: 162]    * print warning message if a class is missing //[ /happyaxis.jsp; Line: 163]    * @param out stream to print stuff //[ /happyaxis.jsp; Line: 164]    * @param classname class to look for //[ /happyaxis.jsp; Line: 165]    * @param jarFile where this class comes from //[ /happyaxis.jsp; Line: 166]    * @param errorText extra error text //[ /happyaxis.jsp; Line: 167]    * @param homePage where to d/l the library //[ /happyaxis.jsp; Line: 168]    * @throws IOException when needed //[ /happyaxis.jsp; Line: 169]    * @return the number of missing libraries (0 or 1) //[ /happyaxis.jsp; Line: 170]    */ //[ /happyaxis.jsp; Line: 171]    int wantClass(JspWriter out, //[ /happyaxis.jsp; Line: 172]    String classname, //[ /happyaxis.jsp; Line: 173]    String jarFile, //[ /happyaxis.jsp; Line: 174]    String description, //[ /happyaxis.jsp; Line: 175]    String errorText, //[ /happyaxis.jsp; Line: 176]    String homePage) throws IOException { //[ /happyaxis.jsp; Line: 177]        return probeClass(out, //[ /happyaxis.jsp; Line: 178]        "<b>Warning</b>", //[ /happyaxis.jsp; Line: 179]        classname, //[ /happyaxis.jsp; Line: 180]        jarFile, //[ /happyaxis.jsp; Line: 181]        description, //[ /happyaxis.jsp; Line: 182]        errorText, //[ /happyaxis.jsp; Line: 183]        homePage); //[ /happyaxis.jsp; Line: 184]    } //[ /happyaxis.jsp; Line: 185]    //[ /happyaxis.jsp; Line: 186]    /** //[ /happyaxis.jsp; Line: 187]    * probe for a resource existing, //[ /happyaxis.jsp; Line: 188]    * @param out //[ /happyaxis.jsp; Line: 189]    * @param resource //[ /happyaxis.jsp; Line: 190]    * @param errorText //[ /happyaxis.jsp; Line: 191]    * @throws Exception //[ /happyaxis.jsp; Line: 192]    */ //[ /happyaxis.jsp; Line: 193]    int wantResource(JspWriter out, //[ /happyaxis.jsp; Line: 194]    String resource, //[ /happyaxis.jsp; Line: 195]    String errorText) throws Exception { //[ /happyaxis.jsp; Line: 196]        if(!resourceExists(resource)) { //[ /happyaxis.jsp; Line: 197]            out.write("<p><b>Warning</b>: could not find resource "+resource //[ /happyaxis.jsp; Line: 198]            +"<br>" //[ /happyaxis.jsp; Line: 199]            +errorText); //[ /happyaxis.jsp; Line: 200]            return 0; //[ /happyaxis.jsp; Line: 201]        } else { //[ /happyaxis.jsp; Line: 202]            out.write("found "+resource+"<br>"); //[ /happyaxis.jsp; Line: 203]            return 1; //[ /happyaxis.jsp; Line: 204]        } //[ /happyaxis.jsp; Line: 205]

⌨️ 快捷键说明

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