001: /*
002: *
003: * The Apache Software License, Version 1.1
004: *
005: * Copyright (c) 1999 The Apache Software Foundation. All rights
006: * reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: *
012: * 1. Redistributions of source code must retain the above copyright
013: * notice, this list of conditions and the following disclaimer.
014: *
015: * 2. Redistributions in binary form must reproduce the above copyright
016: * notice, this list of conditions and the following disclaimer in
017: * the documentation and/or other materials provided with the
018: * distribution.
019: *
020: * 3. The end-user documentation included with the redistribution, if
021: * any, must include the following acknowlegement:
022: * "This product includes software developed by the
023: * Apache Software Foundation (http://www.apache.org/)."
024: * Alternately, this acknowlegement may appear in the software itself,
025: * if and wherever such third-party acknowlegements normally appear.
026: *
027: * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
028: * Foundation" must not be used to endorse or promote products derived
029: * from this software without prior written permission. For written
030: * permission, please contact apache@apache.org.
031: *
032: * 5. Products derived from this software may not be called "Apache"
033: * nor may "Apache" appear in their names without prior written
034: * permission of the Apache Group.
035: *
036: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
040: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047: * SUCH DAMAGE.
048: * ====================================================================
049: *
050: * This software consists of voluntary contributions made by many
051: * individuals on behalf of the Apache Software Foundation. For more
052: * information on the Apache Software Foundation, please see
053: * <http://www.apache.org/>.
054: *
055: */
056:
057: package com.sun.portal.providers.jsp.jasper3.jasper;
058:
059: import java.io.*;
060: import java.util.*;
061: import java.util.logging.Level;
062: import java.util.logging.LogRecord;
063:
064: import com.sun.portal.providers.jsp.jasper3.jasper.compiler.JspReader;
065: import com.sun.portal.providers.jsp.jasper3.jasper.compiler.ServletWriter;
066: import com.sun.portal.providers.jsp.jasper3.jasper.compiler.TagLibraries;
067: import com.sun.portal.providers.jsp.jasper3.jasper.compiler.Compiler;
068: import com.sun.portal.providers.jsp.jasper3.jasper.compiler.SunJavaCompiler;
069: import com.sun.portal.providers.jsp.jasper3.jasper.compiler.JavaCompiler;
070:
071: import com.sun.portal.providers.jsp.jasper3.jasper.servlet.JasperLoader;
072:
073: import com.sun.portal.providers.jsp.jasper3.tomcat.logging.Logger;
074: import com.sun.portal.log.common.PortalLogger;
075:
076: /**
077: * Shell for the jspc compiler. Handles all options associated with the
078: * command line and creates compilation contexts which it then compiles
079: * according to the specified options.
080: * @author Danno Ferrin
081: */
082: public class JspC implements Options { //, JspCompilationContext {
083:
084: public static final String SWITCH_VERBOSE = "-v";
085: public static final String SWITCH_QUIET = "-q";
086: public static final String SWITCH_OUTPUT_DIR = "-d";
087: public static final String SWITCH_OUTPUT_SIMPLE_DIR = "-dd";
088: public static final String SWITCH_IE_CLASS_ID = "-ieplugin";
089: public static final String SWITCH_PACKAGE_NAME = "-p";
090: public static final String SWITCH_CLASS_NAME = "-c";
091: public static final String SWITCH_FULL_STOP = "--";
092: public static final String SWITCH_URI_BASE = "-uribase";
093: public static final String SWITCH_URI_ROOT = "-uriroot";
094: public static final String SWITCH_FILE_WEBAPP = "-webapp";
095: public static final String SWITCH_WEBAPP_INC = "-webinc";
096: public static final String SWITCH_WEBAPP_XML = "-webxml";
097: public static final String SWITCH_MAPPED = "-mapped";
098: public static final String SWITCH_DIE = "-die";
099: // iWS extension
100: public static final String SWITCH_GENERATE_CLASS = "-genclass";
101:
102: public static final int NO_WEBXML = 0;
103: public static final int INC_WEBXML = 10;
104: public static final int ALL_WEBXML = 20;
105:
106: public static final int DEFAULT_DIE_LEVEL = 1;
107: public static final int NO_DIE_LEVEL = 0;
108:
109: // future direction
110: //public static final String SWITCH_XML_OUTPUT = "-xml";
111:
112: boolean largeFile = false;
113: boolean mappedFile = false;
114:
115: int jspVerbosityLevel = Logger.INFORMATION;
116:
117: File scratchDir;
118:
119: String ieClassId;
120:
121: String classPath = "";
122:
123: String targetPackage;
124:
125: String targetClassName;
126:
127: String uriBase;
128:
129: String uriRoot;
130:
131: String webxmlFile;
132:
133: int webxmlLevel;
134:
135: int dieLevel;
136: boolean dieOnExit = false;
137: static int die; // I realize it is duplication, but this is for
138: // the static main catch
139:
140: //JspLoader loader;
141:
142: boolean createPackage = true;
143:
144: Vector extensions;
145:
146: boolean generateClasses = false;
147:
148: private java.util.logging.Logger logger = PortalLogger
149: .getLogger(JspC.class);
150:
151: public boolean getKeepGenerated() {
152: // do not keep generated java files if option to generate class
153: // files is specified
154: if (generateClasses)
155: return false;
156: else
157: return true;
158: }
159:
160: public boolean getLargeFile() {
161: return largeFile;
162: }
163:
164: /**
165: * Are we supporting HTML mapped servlets?
166: */
167: public boolean getMappedFile() {
168: return mappedFile;
169: }
170:
171: // Off-line compiler, no need for security manager
172: public Object getProtectionDomain() {
173: return null;
174: }
175:
176: public boolean getSendErrorToClient() {
177: // implied send to System.err
178: return false;
179: }
180:
181: public boolean getClassDebugInfo() {
182: // compile with debug info
183: return false;
184: }
185:
186: public String getIeClassId() {
187: return ieClassId;
188: }
189:
190: public int getJspVerbosityLevel() {
191: return jspVerbosityLevel;
192: }
193:
194: public File getScratchDir() {
195: return scratchDir;
196: }
197:
198: public Class getJspCompilerPlugin() {
199: Class plugin = null;
200: if (generateClasses) {
201: JavaCompiler javac = new SunJavaCompiler();
202: plugin = javac.getClass();
203: }
204: return plugin;
205: }
206:
207: public String getJspCompilerPath() {
208: // we don't compile, so this is meanlingless
209: return null;
210: }
211:
212: public String getJavaEncoding() {
213: return "UTF-8";
214: }
215:
216: public String getClassPath() {
217: return classPath;
218: }
219:
220: int argPos;
221: // value set by beutifully obsfucscated java
222: boolean fullstop = false;
223: String args[];
224:
225: private void pushBackArg() {
226: if (!fullstop) {
227: argPos--;
228: }
229: }
230:
231: private String nextArg() {
232: if ((argPos >= args.length)
233: || (fullstop = SWITCH_FULL_STOP.equals(args[argPos]))) {
234: return null;
235: } else {
236: return args[argPos++];
237: }
238: }
239:
240: private String nextFile() {
241: if (fullstop)
242: argPos++;
243: if (argPos >= args.length) {
244: return null;
245: } else {
246: return args[argPos++];
247: }
248: }
249:
250: public JspC(String[] arg, PrintStream log) {
251: args = arg;
252: String tok;
253:
254: int verbosityLevel = Logger.WARNING;
255: dieLevel = NO_DIE_LEVEL;
256: die = dieLevel;
257:
258: while ((tok = nextArg()) != null) {
259: if (tok.equals(SWITCH_QUIET)) {
260: verbosityLevel = Logger.WARNING;
261: } else if (tok.equals(SWITCH_VERBOSE)) {
262: verbosityLevel = Logger.INFORMATION;
263: } else if (tok.startsWith(SWITCH_VERBOSE)) {
264: try {
265: verbosityLevel = Integer.parseInt(tok
266: .substring(SWITCH_VERBOSE.length()));
267: } catch (NumberFormatException nfe) {
268: log.println("Verbosity level "
269: + tok.substring(SWITCH_VERBOSE.length())
270: + " is not valid. Option ignored.");
271: }
272: } else if (tok.equals(SWITCH_OUTPUT_DIR)) {
273: tok = nextArg();
274: if (tok != null) {
275: scratchDir = new File(new File(tok)
276: .getAbsolutePath());
277: } else {
278: // either an in-java call with an explicit null
279: // or a "-d --" sequence should cause this,
280: // which would mean default handling
281: /* no-op */
282: scratchDir = null;
283: }
284: } else if (tok.equals(SWITCH_OUTPUT_SIMPLE_DIR)) {
285: tok = nextArg();
286: if (tok != null) {
287: scratchDir = new File(new File(tok)
288: .getAbsolutePath());
289: createPackage = false;
290: } else {
291: // either an in-java call with an explicit null
292: // or a "-d --" sequence should cause this,
293: // which would mean default handling
294: /* no-op */
295: scratchDir = null;
296: }
297: } else if (tok.equals(SWITCH_PACKAGE_NAME)) {
298: targetPackage = nextArg();
299: } else if (tok.equals(SWITCH_CLASS_NAME)) {
300: targetClassName = nextArg();
301: } else if (tok.equals(SWITCH_URI_BASE)) {
302: uriBase = nextArg();
303: } else if (tok.equals(SWITCH_URI_ROOT)) {
304: uriRoot = nextArg();
305: } else if (tok.equals(SWITCH_IE_CLASS_ID)) {
306: ieClassId = nextArg();
307: } else if (tok.equals(SWITCH_WEBAPP_INC)) {
308: webxmlFile = nextArg();
309: if (webxmlFile != null) {
310: webxmlLevel = INC_WEBXML;
311: }
312: } else if (tok.equals(SWITCH_WEBAPP_XML)) {
313: webxmlFile = nextArg();
314: if (webxmlFile != null) {
315: webxmlLevel = ALL_WEBXML;
316: }
317: } else if (tok.equals(SWITCH_MAPPED)) {
318: mappedFile = true;
319: } else if (tok.startsWith(SWITCH_DIE)) {
320: try {
321: dieLevel = Integer.parseInt(tok
322: .substring(SWITCH_DIE.length()));
323: } catch (NumberFormatException nfe) {
324: dieLevel = DEFAULT_DIE_LEVEL;
325: }
326: die = dieLevel;
327: } else if (tok.equals(SWITCH_GENERATE_CLASS)) {
328: generateClasses = true;
329: } else {
330: pushBackArg();
331: // Not a recognized Option? Start treting them as JSP Pages
332: break;
333: }
334: }
335:
336: Constants.jasperLog = new JspCLogger();
337: Constants.jasperLog.setVerbosityLevel(verbosityLevel);
338:
339: }
340:
341: public boolean parseFile(PrintStream log, String file,
342: Writer servletout, Writer mappingout) {
343: try {
344: JasperLoader loader = new JasperLoader();
345: loader.setParentClassLoader(getClass().getClassLoader());
346: loader.setOptions(this );
347: CommandLineContext clctxt = new CommandLineContext(loader,
348: getClassPath(), file, uriBase, uriRoot, false, this );
349: if ((targetClassName != null)
350: && (targetClassName.length() > 0)) {
351: clctxt.setServletClassName(targetClassName);
352: }
353: if (targetPackage != null) {
354: clctxt.setServletPackageName(targetPackage);
355: }
356: clctxt.setPackageFlag(createPackage);
357:
358: File uriDir = new File(clctxt.getRealPath("/"));
359: if (uriDir.exists()) {
360: if ((new File(uriDir, "WEB-INF/classes")).exists()) {
361: loader.addJar(clctxt
362: .getRealPath("/WEB-INF/classes"));
363: }
364: File lib = new File(clctxt.getRealPath("/WEB-INF/lib"));
365: if (lib.exists() && lib.isDirectory()) {
366: String[] libs = lib.list();
367: for (int i = 0; i < libs.length; i++) {
368: try {
369: loader.addJar(lib.getCanonicalPath() + "/"
370: + libs[i]);
371: } catch (IOException ioe) {
372: // failing a toCanonicalPath on a file that
373: // exists() should be a JVM regression test,
374: // therefore we have permission to freak out
375: throw new RuntimeException(ioe.toString());
376: }
377: }
378: }
379: }
380: Compiler compiler = clctxt.createCompiler();
381:
382: compiler.compile();
383:
384: targetClassName = null;
385: String this ServletName;
386: if (clctxt.getServletPackageName() == null) {
387: this ServletName = clctxt.getServletClassName();
388: } else {
389: this ServletName = clctxt.getServletPackageName() + '.'
390: + clctxt.getServletClassName();
391: }
392: if (servletout != null) {
393: servletout.write("\n\t<servlet>\n\t\t<servlet-name>");
394: servletout.write(this ServletName);
395: servletout
396: .write("</servlet-name>\n\t\t<servlet-class>");
397: servletout.write(this ServletName);
398: servletout.write("</servlet-class>\n\t</servlet>\n");
399: }
400: if (mappingout != null) {
401: mappingout
402: .write("\n\t<servlet-mapping>\n\t\t<url-pattern>");
403: mappingout.write(file);
404: mappingout.write("</url-pattern>\n\t\t<servlet-name>");
405: mappingout.write(this ServletName);
406: mappingout
407: .write("</servlet-name>\n\t</servlet-mapping>\n");
408: }
409: return true;
410: } catch (JasperException je) {
411: //je.printStackTrace(log);
412: if (logger.isLoggable(Level.WARNING)) {
413: LogRecord record = new LogRecord(Level.WARNING,
414: "PSDT_CSPPJJJ0009");
415: record.setLoggerName(logger.getName());
416: record.setParameters(new Object[] { file });
417: record.setThrown(je);
418: logger.log(record);
419: }
420: if (dieLevel != NO_DIE_LEVEL) {
421: dieOnExit = true;
422: }
423: } catch (FileNotFoundException fne) {
424: if (logger.isLoggable(Level.WARNING)) {
425: LogRecord record = new LogRecord(Level.WARNING,
426: "PSDT_CSPPJJJ0009");
427: record.setLoggerName(logger.getName());
428: record.setParameters(new Object[] { file });
429: record.setThrown(fne);
430: logger.log(record);
431: }
432: } catch (Exception e) {
433: if (logger.isLoggable(Level.WARNING)) {
434: LogRecord record = new LogRecord(Level.WARNING,
435: "PSDT_CSPPJJJ0009");
436: record.setLoggerName(logger.getName());
437: record.setParameters(new Object[] { file });
438: record.setThrown(e);
439: logger.log(record);
440: }
441: if (dieLevel != NO_DIE_LEVEL) {
442: dieOnExit = true;
443: }
444: }
445: return false;
446: }
447:
448: public void parseFiles(PrintStream log) throws JasperException {
449:
450: boolean scratchDirSet = (scratchDir != null);
451: boolean urirootSet = (uriRoot != null);
452:
453: // set up a scratch/output dir if none is provided
454: if (scratchDir == null) {
455: String temp = System.getProperty("java.io.tempdir");
456: if (temp == null) {
457: temp = "";
458: }
459: scratchDir = new File(new File(temp).getAbsolutePath());
460: }
461:
462: File f = new File(args[argPos]);
463: while (!f.exists()) {
464: boolean webApp = false;
465: if (SWITCH_FILE_WEBAPP.equals(args[argPos])) {
466: webApp = true;
467: if (args.length > argPos + 1) {
468: f = new File(args[argPos + 1]);
469: } else {
470: // end of arguments, nothing left to parse
471: logger.finest("PSDT_CSPPJJJ0010");
472: return;
473: }
474: }
475: if (!f.exists()) {
476: logger.log(Level.FINE, "PSDT_CSPPJJJ0011",
477: new Object[] { f.toString() });
478: argPos++;
479: if (webApp) {
480: argPos++;
481: }
482: if (argPos >= args.length) {
483: // end of arguments, nothing left to parse
484: return;
485: } else {
486: f = new File(args[argPos]);
487: }
488: }
489: }
490: if (uriRoot == null) {
491: if (SWITCH_FILE_WEBAPP.equals(args[argPos])) {
492: if (args.length > argPos + 1) {
493: f = new File(args[argPos + 1]);
494: } else {
495: // end of arguments, nothing left to parse
496: return;
497: }
498: }
499: // set up the uri root if none is explicitly set
500: String tUriBase = uriBase;
501: if (tUriBase == null) {
502: tUriBase = "/";
503: }
504: try {
505: if (f.exists()) {
506: f = new File(f.getCanonicalPath());
507: while (f != null) {
508: File g = new File(f, "WEB-INF");
509: if (g.exists() && g.isDirectory()) {
510: uriRoot = f.getCanonicalPath();
511: uriBase = tUriBase;
512: logger.log(Level.FINEST,
513: "PSDT_CSPPJJJ0012",
514: new Object[] { uriRoot });
515: break;
516: }
517: if (f.exists() && f.isDirectory()) {
518: tUriBase = "/" + f.getName() + "/"
519: + tUriBase;
520: }
521:
522: String fParent = f.getParent();
523: if (fParent == null) {
524: f = new File(args[argPos]);
525: fParent = f.getParent();
526: if (fParent == null) {
527: fParent = ".";
528: }
529: uriRoot = new File(fParent)
530: .getCanonicalPath();
531: uriBase = "/";
532: break;
533: } else {
534: f = new File(fParent);
535: }
536:
537: // If there is no acceptible candidate, uriRoot will
538: // remain null to indicate to the CompilerContext to
539: // use the current working/user dir.
540: }
541: }
542: } catch (IOException ioe) {
543: // since this is an optional default and a null value
544: // for uriRoot has a non-error meaning, we can just
545: // pass straight through
546: }
547: }
548:
549: String file = nextFile();
550: File froot = new File(uriRoot);
551: String ubase = null;
552: try {
553: ubase = froot.getCanonicalPath();
554: } catch (IOException ioe) {
555: // if we cannot get the base, leave it null
556: }
557:
558: while (file != null) {
559: if (SWITCH_FILE_WEBAPP.equals(file)) {
560: String base = nextFile();
561: if (base == null) {
562: logger.warning("PSDT_CSPPJJJ0010");
563: return;
564: }// else if (".".equals(base)) {
565: // base = "";
566: //}
567: String oldRoot = uriRoot;
568: if (!urirootSet) {
569: uriRoot = base;
570: }
571: Vector pages = new Vector();
572:
573: Stack dirs = new Stack();
574: dirs.push(base);
575: if (extensions == null) {
576: extensions = new Vector();
577: extensions.addElement("jsp");
578: }
579: while (!dirs.isEmpty()) {
580: String s = dirs.pop().toString();
581: //System.out.println("--" + s);
582: f = new File(s);
583: if (f.exists() && f.isDirectory()) {
584: String[] files = f.list();
585: String ext;
586: for (int i = 0; i < files.length; i++) {
587: File f2 = new File(s, files[i]);
588: //System.out.println(":" + f2.getPath());
589: if (f2.isDirectory()) {
590: dirs.push(f2.getPath());
591: //System.out.println("++" + f2.getPath());
592: } else {
593: ext = files[i].substring(files[i]
594: .lastIndexOf('.') + 1);
595: if (extensions.contains(ext)) {
596: //System.out.println(s + "?" + files[i]);
597: pages.addElement(s
598: + File.separatorChar
599: + files[i]);
600: } else {
601: //System.out.println("not done:" + ext);
602: }
603: }
604: }
605: }
606: }
607:
608: String ubaseOld = ubase;
609: File frootOld = froot;
610: froot = new File(uriRoot);
611:
612: try {
613: ubase = froot.getCanonicalPath();
614: } catch (IOException ioe) {
615: // if we cannot get the base, leave it null
616: }
617:
618: //System.out.println("==" + ubase);
619:
620: Writer mapout;
621: CharArrayWriter servletout, mappingout;
622: try {
623: if (webxmlLevel >= INC_WEBXML) {
624: File fmapings = new File(webxmlFile);
625: mapout = new FileWriter(fmapings);
626: servletout = new CharArrayWriter();
627: mappingout = new CharArrayWriter();
628: } else {
629: mapout = null;
630: servletout = null;
631: mappingout = null;
632: }
633: if (webxmlLevel >= ALL_WEBXML) {
634: mapout.write(Constants
635: .getString("jspc.webxml.header"));
636: } else if (webxmlLevel >= INC_WEBXML) {
637: mapout.write(Constants
638: .getString("jspc.webinc.header"));
639: }
640: } catch (IOException ioe) {
641: mapout = null;
642: servletout = null;
643: mappingout = null;
644: }
645:
646: Enumeration e = pages.elements();
647: while (e.hasMoreElements()) {
648: String nextjsp = e.nextElement().toString();
649: try {
650: if (ubase != null) {
651: File fjsp = new File(nextjsp);
652: String s = fjsp.getCanonicalPath();
653: //System.out.println("**" + s);
654: if (s.startsWith(ubase)) {
655: nextjsp = s.substring(ubase.length());
656: }
657: }
658: } catch (IOException ioe) {
659: // if we got problems dont change the file name
660: }
661:
662: if (nextjsp.startsWith("." + File.separatorChar)) {
663: nextjsp = nextjsp.substring(2);
664: }
665:
666: parseFile(log, nextjsp, servletout, mappingout);
667: }
668: uriRoot = oldRoot;
669: ubase = ubaseOld;
670: froot = frootOld;
671:
672: if (mapout != null) {
673: try {
674: servletout.writeTo(mapout);
675: mappingout.writeTo(mapout);
676: if (webxmlLevel >= ALL_WEBXML) {
677: mapout.write(Constants
678: .getString("jspc.webxml.footer"));
679: } else if (webxmlLevel >= INC_WEBXML) {
680: mapout.write(Constants
681: .getString("jspc.webinc.footer"));
682: }
683: mapout.close();
684: } catch (IOException ioe) {
685: // noting to do if it fails since we are done with it
686: }
687: }
688: } else {
689: try {
690: if (ubase != null) {
691: File fjsp = new File(file);
692: String s = fjsp.getCanonicalPath();
693: if (s.startsWith(ubase)) {
694: file = s.substring(ubase.length());
695: }
696: }
697: } catch (IOException ioe) {
698: // if we got problems dont change the file name
699: }
700:
701: parseFile(log, file, null, null);
702: }
703: file = nextFile();
704: }
705: if (dieOnExit) {
706: System.exit(die);
707: }
708: }
709:
710: private static void validateArgs(String[] args)
711: throws JasperException {
712: int minArgLength = 6;
713: Hashtable intern_table = new Hashtable();
714: for (int loopCount = 0; loopCount < args.length - 1; loopCount++) {
715: if ((args[loopCount].equals(SWITCH_WEBAPP_XML))
716: || (args[loopCount].equals(SWITCH_WEBAPP_INC))
717: || (args[loopCount].equals(SWITCH_FILE_WEBAPP))) {
718: intern_table.put(args[loopCount], args[loopCount + 1]);
719: }
720: }
721: if ((intern_table.containsKey(SWITCH_WEBAPP_INC))
722: || (intern_table.containsKey(SWITCH_WEBAPP_XML))) {
723: if (!intern_table.containsKey(SWITCH_FILE_WEBAPP))
724: throw new JasperException(
725: "Specify webapps directory with -webapp option.");
726: } else {
727: File tempDir = new File(args[args.length - 1]);
728: if (!tempDir.exists())
729: throw new JasperException(
730: "Invalid file or webapps directory to compile.Check whether they exist or not.");
731: else {
732: if (!tempDir.canRead())
733: throw new JasperException(
734: "Cannot read file or webapps directory to compile.Change the permission.");
735: }
736: if (!intern_table.containsKey(SWITCH_FILE_WEBAPP)) {
737: if (tempDir.isDirectory())
738: throw new JasperException(
739: "Specify the webapp directory with -webapp option.");
740: }
741: }
742:
743: }
744:
745: public static void main(String arg[]) {
746: if (arg.length == 0) {
747: System.out.println(Constants.getString("jspc.usage"));
748: } else {
749: try {
750: validateArgs(arg);
751: JspC jspc = new JspC(arg, System.out);
752: jspc.parseFiles(System.out);
753: } catch (JasperException je) {
754: System.err.print("error:");
755: System.err.println(je.getMessage());
756: if (die != NO_DIE_LEVEL) {
757: System.exit(die);
758: }
759: }
760: }
761: }
762:
763: }
|