The principle is very simple. Although some JSP WebServer provides pre-compiled features, you can also try it yourself. Mainly uses Java's httpurlconnection and java.io. *; the following is console code: package sam.bobpig.com Import java.io. *; import java.net. *; / ** *
Title: ASP.NET or JSP precompile program p> *
description: p> *
Copyright: Copyright (C) 2004 P> *
Company: Chongqing flight digital company p> * @Author Song Yunyi * @version 1.0 * /
Public class precomplie {public static filefilter filefilter = new precompilefilefilter (); public url rooturl
Public precomplie (url arooturl) {rooturl = arbooturl;
// public void precompiledirectory (file dir, string startdir) {file [] files = dir.listfiles (filefilter); for (int i = 0; i Public void precompilefile (file file, string startdir) {Try {url precompileurl = new url (rooturl, startdir "/" file.getname () "ASP_PRE = true"); //System.out.println (rooturl.tostring ()); system.out.println (precompileurl.tostring ()); HttpURLConnection conn = (HttpURLConnection) precompileURL.openConnection (); int responseCode = conn.getResponseCode (); System.out.println (rootURL startDir "/" file.getName () "has ok! [" ResponseCode "] ");} Catch (Exception Exc) {system.out.println (" Exception: " EXC.TOSTRING () " for " startdir file.getname ()); } Public static void main (string [] args) {if (Args.Length <2) {system.out.print ("please supportory ..."); system.exit (0);} Try {string starturl = args [0]; file start = new file (args [1]); Precomplie Precomp = New Precomplie (New URL); IF (Start.Indirectory ()) {Precomp.Precompiledirectory (Start, ");} else {precomp.precompilefile (start,");}} catch (exception eXC) {EXC.PRINTSTACKTRACE (); } Class Precompilefilefilter Implements Filefilter {Public Boolean Accept (F.IsDirectory ()) Return True; if (F.GetName (). Endswith (". aspx")) Return True; Return False;}}