---------------------------------------------------
Post Server Startup JSP File Compiler and Validator
---------------------------------------------------
This utility helps to
1. Simulate a precompilation of jsp´s after the server
has already started up.
This way, we do not have to wait for all the jsp´s to be precompiled
before starting up the server.
2. Test the validity of all the jsp´s. If any jsp does not compile, a
response code of 500 is returned. The tool lists that jsp, so it can
be worked on.
The list of jsp targets to be precompiled must be supplied in a plain
text file.
A sample is below:
#---------------------------------------------
/console/index.jsp
/console/standards/home.jsp
#---------------------------------------------
All the targets defined in there a hit sequentially, the response code
monitored and such information relayed to the user.
Usage:
java TestJSPFiles <fName>
If you specify no parameters, this help will be displayed
At least one parameter, the fileName should be specified
Below simulates the default argument list (if no parameters are passed in)
jsp-pages.txt
If form based authentication is required, then send the username and parameters
System Properties, passed using the -D flag, are used to set the argument
list. They are listed below:
host the hostname or ip address of the machine
port the port the server is listening on
debug If true, extra information like the actual output string
is written to std error stream
If authentication is required to view some of the pages, the following
will be required.
username The username to login as
password The password for that user
formauthtarget The j_security_check target. By default, it is
/j_security_check. It can be specified as the login
page may vary.
At the end, we tell you how many pages were OK (returned 200)
and how many were broken (including list of broken pages).
This will help you know which pages are broken immediately.
Any pages already precompiled will not precompile again.
Thus, there is no performance hit on running this script
multiple times.
**** NOTE ****
The file passed should have the full path of pages to precompile
Example Scenario:
webapp context-path is /console
to precompile the jsp pages, index.jsp and standards/home.jsp in there
File should be as below
#---------------------------------------------
/console/index.jsp
/console/standards/home.jsp
/**
* Precompiles all the jsp and tell us which are broken
* <xmp>To see Usage Information: java weblogic.qa.taskmgr.TestJSPFiles</xmp>
* fName is the list of files with the paths of JSP files to precompile
* host and port are the server host and port respectively
*
* Currently, this is only geared towards FORM-based authenticated sites
*
* @author Ugorji Dick-Nwoke ugorji.dick-nwoke@bea.com
* @version 1.0, August 3, 2001
*/
public class TestJSPFiles
{
private static String HELP_MESSAGE = null;
public boolean DEBUG = false;
public List jspFiles;
public String host;
public int port;
public String username;
public String password;
public String cookieString;
public String formAuthTarget = "/j_security_check";
public String toString () {
String s = host + ":" + port + " [user/pass=" + username + "/" + password + "]";
return s;
}
public void run ()
throws Exception
{
cookieString = getCookieString ();
if (DEBUG) System.err.println (cookieString);
List badFiles = new ArrayList ();
List goodFiles = new ArrayList ();
int numGood = 0;
int numBad = 0;