This week's giveaway is in the Java/Jakarta EE forum.
We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line!
It worked for me, and being a couple of years removed from it, I started thinking about why it did work - seems like the "header.jsp" (the file to be included) should fail to get compiled properly....

I think the answer is in that I was doing a compile-time include:

as opposed to a run-time:

I think of the compile-time include like a C "#include", where the source is directly copied into the
JSP, then the combined page compiled... so by the time the code inside the "header.jsp" is compiled, it's in the context of a page that has defined those variables.

Bottom line, here's my understanding:

If you're using the

method of including, you should just be able to reference those variables directly. If not, you'll have to set them into the request (or session, but to me, request sounds more like what you want), and retrieve them back out of the request in the included page.

.... ok... and I just found this looking through the docs on Sun's JSP Site :

A declaration has translation unit scope, so it is valid in the JSP page and any of its static include files. A static include file becomes part of the source of the JSP page and is any file included with an include directive or a static resource included with a <jsp:include> element. The scope of a declaration does not include dynamic resources included with <jsp:include>.

Hope this helps.

-- Jon Egan
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi rastas biggs,

Just search for jsp aram tag. Using this, you can pass the data as parameters to the included page and use it there.
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<jsp:param> simply adds (or removes) request parameters that the included page can use. In the main jsp page:In the included file:Of course, this example is using EL. If you don't use EL, then you can replace the "${}" with some scripting to retrieve the parameters.
[ April 18, 2005: Message edited by: Paul Bourdeaux ]
rastas biggs
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this JSP 1.2 compilant.

I assume rather than EL I can use the request object to get the params?

I'm just going to use the request object.

[ April 18, 2005: Message edited by: rastas biggs ]
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!