手工编译jsp

A java-classpath jasper.jar;servlet-api.jar;catalina.jar;F:\server\tomcat.6\bin\tomcat-juli.jar;ant.jar;jsp-

 

api.jar;jasper-el.jar;el-api.jar;jstl.jar;standard.jar;jasper-el.jar;jasper-jdt.jar org.apache.jasper.JspC  -

 

uriroot ./temp -d temp temp.jsp

JspC类在jasper.jar

运行上边的命令 因为用到jstl标签。所以有jstl.jar standard.jar.上边那些jar都是tomcat中的jar,另外需要个antjar

 

下边是tomcat源码TldLocationsCache.java中看到的,看不明白。估计需要这些jar,我只用了上边的A处的。

noTldJars = new HashSet<String>();

        // Bootstrap JARs

        noTldJars.add("bootstrap.jar");

        noTldJars.add("commons-daemon.jar");

        noTldJars.add("tomcat-juli.jar");

        // Main JARs

        noTldJars.add("annotations-api.jar");

        noTldJars.add("catalina.jar");

        noTldJars.add("catalina-ant.jar");

        noTldJars.add("catalina-ha.jar");

        noTldJars.add("catalina-tribes.jar");

        noTldJars.add("el-api.jar");

        noTldJars.add("jasper.jar");

        noTldJars.add("jasper-el.jar");

        noTldJars.add("jasper-jdt.jar");

        noTldJars.add("jsp-api.jar");

        noTldJars.add("servlet-api.jar");

        noTldJars.add("tomcat-coyote.jar");

        noTldJars.add("tomcat-dbcp.jar");

        // i18n JARs

        noTldJars.add("tomcat-i18n-en.jar");

        noTldJars.add("tomcat-i18n-es.jar");

        noTldJars.add("tomcat-i18n-fr.jar");

        noTldJars.add("tomcat-i18n-ja.jar");

        // Misc JARs not included with Tomcat

        noTldJars.add("ant.jar");

        noTldJars.add("commons-dbcp.jar");

        noTldJars.add("commons-beanutils.jar");

        noTldJars.add("commons-fileupload-1.0.jar");

        noTldJars.add("commons-pool.jar");

        noTldJars.add("commons-digester.jar");

        noTldJars.add("commons-logging.jar");

        noTldJars.add("commons-collections.jar");

        noTldJars.add("jmx.jar");

        noTldJars.add("jmx-tools.jar");

        noTldJars.add("xercesImpl.jar");

        noTldJars.add("xmlParserAPIs.jar");

        noTldJars.add("xml-apis.jar");

        // JARs from J2SE runtime

        noTldJars.add("sunjce_provider.jar");

        noTldJars.add("ldapsec.jar");

        noTldJars.add("localedata.jar");

        noTldJars.add("dnsns.jar");

        noTldJars.add("tools.jar"); j2eelib下的jar

        noTldJars.add("sunpkcs11.jar");

我的目录结构F:/server/tomcat.6/lib

F:/server/tomcat.6/lib/jspC.bat

F:/server/tomcat.6/lib/temp/temp.jsp

F:/server/tomcat.6/lib/temp/WEB-INF/web.xml 编译jstl的话需要用到web.xml.

F:/server/tomcat.6/lib/temp/c.tld 编译jstl的话需要用到c.tld,standard.jarMETA-INF目录中解压出来。

 

 

jspC.bat 就是上边A 的编译命令。

我在tomcat/lib 目录下编译

不用jstl的话。在temp目录中建立temp.jsp如下,运行上边命令。在temp目录下就生成了org.apache.jsp.temp_jsp.javaservlet原文件。

 

<%@page pageEncoding="utf-8"%>

<html>

    <head>hello</head>

    <body>

    </body>

</html>

 

需要编译包含jstljsp的话,需要用到web.xml

Temp.jsp改为如下

<%@page pageEncoding="utf-8"%>

<%@ taglib prefix="c" uri="c.tld"%>

<html>

    <head>hello</head>

    <body>

   

       <c:out value="helloWorld"></c:out>

    </body>

</html>

 

Web.xml中定义如下:刚发现dtdj2ee/lib/dtds中可以找到。

<!DOCTYPE web-app PUBLIC

    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

    "http://java.sun.com/dtd/web-app_2_3.dtd"> 

<web-app>

    <jsp-config>

   <taglib>

        <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>//uri就是c.tld中声明的uri

       <taglib-location>c.tld</taglib-location>就是temp目录下的c.tld

    如果是stardard.jar

     </taglib>

     </jsp-config>

</web-app>

如果是stardard.jar就是找jar包中就找下边这个路径。

"META-INF/taglib.tld";

运行上边A处命令可以编译。同样在temp.jsp中生成一个org.apache.jsp.temp_jsp.java文件.

如果运行出错:没有堆栈信息。或者提供信息不多。因为代码中没有e.printstacktract().我的办法是把tomcat源码下载下来 。手动加上e.printstacktract()

运行jspC.java文件。

jspC编译参数如下:可以运行改下上边A JspC –help列出编译应该是运行参数

protected static Log log = LogFactory.getLog(JspC.class);

 

    protected static final String SWITCH_VERBOSE = "-v";

    protected static final String SWITCH_HELP = "-help";

    protected static final String SWITCH_OUTPUT_DIR = "-d";

    protected static final String SWITCH_PACKAGE_NAME = "-p";

    protected static final String SWITCH_CACHE = "-cache";

    protected static final String SWITCH_CLASS_NAME = "-c";

    protected static final String SWITCH_FULL_STOP = "--";

    protected static final String SWITCH_COMPILE = "-compile";

    protected static final String SWITCH_SOURCE = "-source";

    protected static final String SWITCH_TARGET = "-target";

    protected static final String SWITCH_URI_BASE = "-uribase";

    protected static final String <span styl

你可能感兴趣的:(tomcat,jsp,Web,ant,C#)