Santosh Asbe wrote:
Hi,
i have tried to use the code for pre compilation of JSP from the site <
http://www.rgagnon.com/javadetails/java-0414.html>.
In my Application in the JSP folder , there around 6 sub folders and around
25-30 JSP is each of them. When i run this JSP only few JSP's are complied
and then an error is given in the catalina.sh as folows. Can anyone help me
regarding this.
You'll need to catch exceptions from RequestDispatcher#include() to get
past that point, e.g. (with acknowledgements to Réal Gagnon)
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="javax.servlet.*,javax.servlet.http.*,javax.servlet.jsp.*"%>
<%@ page import="java.util.Set,java.util.Iterator,java.io.IOException"%>
<%! private int compileAllJsps(PageContext pageContext, JspWriter out,
HttpServletRequest request,HttpServletResponse response, String uripath, boolean
recurse) throws IOException, ServletException {
Set set = pageContext.getServletContext().getResourcePaths(uripath);
int n = 0;
out.flush();
for ( Iterator iter=set.iterator() ; iter.hasNext() ; ) {
String uri = (String) iter.next();
if ( uri.endsWith(".jsp") ) {
RequestDispatcher rd = getServletContext().getRequestDispatcher(uri);
try {
if ( rd == null ) {
throw new Error(uri +" - not found");
} else {
rd.include(request, response);
n++;
}
} catch ( Exception e ) {
out.write("<div>" + uri + " " + "<i>"+e.toString()+"</i></div>");
out.flush();
}
} else if ( recurse && uri.endsWith("/") ) {
compileAllJsps(pageContext, out, request, response, uri, recurse); //
process subfolders
}
}
return n;
}
%>
<html>
<head>
<title>precompiling JSPs</title>
</head>
<body>
<h4>precompiling JSPs</h4>
<% HttpServletRequest req = new HttpServletRequestWrapper(request) {
public String getQueryString() {
return "jsp_precompile"; // can be "jsp_precompile=true"
};
};
int ok = compileAllJsps(pageContext, out, req, response, "/", false);
%>
<h4><%= ok %> JSPs (now) appear to be compiled</h4>
</body>
</html>
Paul Singleton
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.12.4/142 - Release Date: 18/Oct/2005
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]