Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Using c:import to include page elements?  RSS feed

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I think I'm barking up the wrong tree here, but don't know the "right" way to go about it.

In a nutshell:
I'm creating a site with a significant amount of pages (using ICEfaces but I don't think that's relevant to my issue) and will have a navigation bar at the top of each page.
Obviously, I don't want to replicate (and maintain...) the nav bar code in each page I create, so I'm looking at how one imports page content from another page.

What I've done so far is create a separate file called Navigation.jspx. I've tried leaving it as a fully-formed page on its own, and also as a "broken" JSP document that only has the JSP code I want.
Then, in my "real" pages, I used syntax like this:


What I am hoping to happen (clearly it doesn't work this way) is that the import statement will essentially pull in all the page content of my Navigation.jspx and plop it in place in my main page, at which time Jboss will render the whole combined page.

That's my fuzzy little dream world, anyways.

Can anyone point me towards the proper mechanism for including shared content into a page? It's obviously done all over the place but I'm clearly lacking a fundamental concept in getting this to work.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to include the contents of the file before it is translated into a Servlet, use the <%@ include file="filename" %> directive instead of <c:import> tag.
 
Author and ninkuma
Marshal
Posts: 66806
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It'd be much cleaner to use a custom tag -- which in JSP 2.0, is almost trivially easy to set up. (Hint: tag files).
[ March 18, 2008: Message edited by: Bear Bibeault ]
 
Stefan Mohr
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Merrill and Bear both!

My initial errors I was seeing were due to ICEfaces getting upset about using a static jsp include on a jspx file.

I'm doing a little research into tags and it looks like a graceful way to go about it - thanks!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!