Compiling JSP files with Org.apache.jasper.JspC--reprint

Source: Internet
Author: User

The JSPC can be Jspc.setargs (args), set the required parameters, and compile the same with the instructions.

Use the instructions to compile the example:

JAVA-CP Jasper.jar;servlet-api.jar; Fcatalina.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

You can also set parameters by calling the Set method

Java code
  1. Public class Test1 {
  2. Public String Jspctest () {
  3. String error="";
  4. try {
  5. JSPC JSPC = new JSPC ();
  6. /*string[] arg0 = {"-uriroot", "E:/JSPC", "-D", "d:/t",
  7. "Temp/temp.jsp"};
  8. Jspc.setargs (ARG0); * *
  9. Jspc.seturiroot ("D:/JSPC"); Web app's root directory
  10. Jspc.setoutputdir ("d:/t"); Output directories for. java files and. class Files
  11. Jspc.setjspfiles ("temp/temp.jsp"); The JSP to be compiled
  12. Jspc.setcompile (true); Whether to compile false or not specify only the. java file is generated
  13. Jspc.execute ();
  14. } catch (Exception e) {
  15. Error=e.tostring ();
  16. }
  17. return error;
  18. }
  19. public static void Main (String args[]) {
  20. Test1 t=New Test1 ();
  21. System.out.println (T.jspctest ());
  22. }
  23. }

Here the jar packages are referenced from Tomcat

The test class compiles the necessary jar packages:

D:/tomcat5.5/common/lib/jasper-compiler.jar

D:/tomcat5.5/common/lib/jasper-runtime.jar

JSP compiles the necessary jar packages, in addition to the jar that references the class in the JSP:

D:/tomcat5.5/common/lib/commons-el.jar
D:/tomcat5.5/common/lib/jasper-compiler.jar
D:/tomcat5.5/bin/commons-logging-api-1.1.1.jar
D:/tomcat5.5/common/lib/jsp-api.jar
D:/tomcat5.5/common/lib/jasper-compiler-jdt.jar
D:/tomcat5.5/common/lib/servlet-api.jar
D:/tomcat5.5/common/lib/jasper-runtime.jar
D:/tomcat5.5/server/lib/catalina-ant.jar

If you are running the engineering environment in a Tomcat Web environment, add the ant jar to

Original: http://kjah.iteye.com/blog/625588

Compiling JSP files with Org.apache.jasper.JspC--reprint

Related Article

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.