• 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • 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.
 
Marshal
Posts: 67254
170
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!
 
The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!