File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes jsp:include using jsp_precompile question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:include using jsp_precompile question" Watch "jsp:include using jsp_precompile question" New topic

jsp:include using jsp_precompile question

michael warren

Joined: Mar 04, 2004
Posts: 8
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 ]
David Valentine

Joined: Mar 04, 2004
Posts: 1
There is an ant task to do page precompiling for Tomcat.
Also useful for general development, if it does not compile, no use hitting the webserver
Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
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"
michael warren

Joined: Mar 04, 2004
Posts: 8
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.
Peter Lg

Joined: Jun 06, 2006
Posts: 1
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.

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.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63866

"Peter Lg",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

JavaRanch Sheriff

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: jsp:include using jsp_precompile question
It's not a secret anymore!