• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Importing HTML code blocks

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy all.

Is there anyway to import HTML code from one page into another?

My pages are .JSPs, and normally I would use the jsp:include method, but in this case, because I'm importing (intentionally) incomplete code, it won't allow that.

To specify: I've got a table with three columns and three rows.

The first and last rows and columns are borders (images), the middle spot is used to insert an inner table. The obvious effect is a table with an outer border of my choosing.

This works well, but the code I have to set it up it rather lengthy, and often repeated.

What I would like is, essentially, to be able to just do

html:import value ="../tableTop.html"
A table
html:import value ="../tableBottom.html"

Problem is that the table top would end with many unclosed tags and table bottom would close many seemingly unexisting ones.

I suppose basically I want a dumb importer that doesn't care what it's getting, just copies and pastes all the text from a specified file.

Any ideas?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could use the <%@ include %> JSP directive to include fragments, but my preference is to custom actions (formerly known as custom tags).
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HTML doe snot have any way to include information from other places, you are better off doing what Bear says.

Eric
 
Karl Beowulph
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well this is humbling.

I found out that the code wasn't importing, not because it was a fragment as I thought, but because it can't be found in it's current directory.

I find this confusing though. I can include the fragment if it's in a directory, but not if it's in a sub directory.

Currently it's like this (working): jsp:include "../formating/tableBorderTop.jsp"

but, when I make it like this: jsp:include "../formating/table/tableBorderTop.jsp"

It can't find it, even with tableBorder in the appropriate sub-folder. I've tried several times, so I think I can rule out human error on this one.

Any ideas?

This is a struts application deployed using JBoss if that makes any difference.
 
Lookout! Runaway whale! Hide behind this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic