This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hi, I was hoping to create a precompile.JSP that would precompile all other JSPs, based on using the jsp:include action something like this:-
When I try this is seems to ignore the jsp_precompile parameter, and the output from test.jsp gets included in the output of precompile.jsp I know there are ant scripts that will precompile JSPs, but I'm not familiar with ant and thought that this would be an easy solution.
Should it work, or am I missing something obvious? [ March 04, 2004: Message edited by: michael warren ] [ March 04, 2004: Message edited by: michael warren ] [ March 04, 2004: Message edited by: michael warren ]
if you are using <jsp:include> action page will be compiled (if not already compiled) no matter what parameters are you sending.
Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
Joined: Mar 04, 2004
Thanks for your answers, I know there are ant scripts that will precompile JSPs. I also know that <jsp:include> will result in included page being compiled if not already compiled, but I don't want the output of the jsp included, just for it to be compiled. Since I know I can use ant scripts to do what I want I suppose its academic, but I would still like to understand why sending the jsp_precompile parameter when using <jsp:include> doesn't seem to have any effect. Just to explain, JSPs can be "precompiled" using the jsp_precompile parameter as below, resulting in no output if the page is compiled OK. I was hoping to create a JSP page that would locate all other JSPs in its directory and sub-directories and compile them, displaying a list of any pages that have errors. I'm just about to start learning about ant, but liked the idea of being able to have a standard JSP that would work without needing the ant or anything other than a standard JSP container to work.
For the sake of completeness I'm posting what I think is a work-around / solution to this problem. My experiments seem successful.
Not sure why jsp:include does not properly post the dynamic request parameter but if it's a bonafide request parameter then everything works. Unfortunately this precludes using a JSP to do the inclusions.
If you create a servlet (EG: JspPrecompile) and call it using the jsp_precompile=true parameter then you can include the jsp's you wish to pre-compile. This works even if the jsp is in a protected part of the app.
PSEUDO-CODE... IF 'jsp_precompile=true' parameter is present THEN include the desired jsp's you wish to compile ELSE send redirect to self + ?jsp_precompile=true
Caveat: Make sure you include the 'no-cache' directives / headers.