File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using c:import to include page elements?

 
Stefan Mohr
Greenhorn
Posts: 14
  • 0
  • 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.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • 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
  • 0
  • 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!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic