Results 1 to 1 of 1
-
JSP page to compile all the JSP pages in a directory
The JSP page presented below will precompile all the JSP pages found in the current directory and all its subdirectories.
Java Code:<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page import="javax.servlet.*"%> <%@ page import="javax.servlet.http.*,javax.servlet.jsp.*"%> <%@ page import="java.util.Set,java.util.Iterator,java.io.IOException"%> <%! private void compileAllJsps (PageContext pageContext, JspWriter out, HttpServletRequest request,HttpServletResponse response, String uripath) throws IOException, ServletException { Set set = pageContext.getServletContext().getResourcePaths(uripath); for (Iterator iter = set.iterator(); iter.hasNext();) { String uri = (String) iter.next(); if (uri.endsWith(".jsp")) { out.write("<li>"+ uri +"</li>"); out.flush(); RequestDispatcher rd = getServletContext().getRequestDispatcher(uri); if (rd == null) { throw new Error(uri +" - not found"); } rd.include(request, response); } else if (uri.endsWith("/")) { compileAllJsps(pageContext, out, request, response, uri); } } } %> <html><head><title>Precompiling *.JSPs</title></head> <body><h4>Precompiling *.JSPs:</h4> <ul> <% HttpServletRequest req = new HttpServletRequestWrapper(request) { public String getQueryString() { // can be "jsp_precompile=true" return "jsp_precompile"; }; }; compileAllJsps(pageContext, out, req, response, "/"); %> </ul> <h4>Done.</h4> </body> </html>
Similar Threads
-
How to compile an applet to an exe
By elizabeth in forum Java AppletsReplies: 4Last Post: 02-18-2008, 03:57 AM -
Unable to compile
By gapper in forum New To JavaReplies: 2Last Post: 01-14-2008, 04:31 PM -
Not able to compile
By bugger in forum New To JavaReplies: 2Last Post: 01-09-2008, 10:13 PM -
Getting all the pages from a domain
By eva in forum New To JavaReplies: 0Last Post: 12-25-2007, 11:41 AM -
compile error
By dirtycash in forum New To JavaReplies: 6Last Post: 12-12-2007, 06:00 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks