• 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

jsp:include/c:import acting like include directive?

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hola all, I've cross posted this issue at the sun developer forums but it's driving me nuts and I'm hoping that I might get some different/additional insight here.

Basically what I have is a page using either jsp:include or c:import (I say either as I've tried using both) to include a jspf fragment. The fragment imports several taglibs (displaytag, ajaxtags, etc.,) and renders a table. Instead of the page using the c:import/jsp:include getting the response/rendering of the imported/included page, it's getting the source code of the included page, taglib declarations and all!

here is the jspf file:



I'd paste the source code of the page using the import to import this fragment but it's on a separate network and I don't care to type that much in ;-)

The code using <c:import url="WEB-INF/jsp/pagefragement.jspf" />
or <jsp:include page="WEB-INF/jsp/pagefragment.jspf" /> (these tags actually have a body with some parameters being set for the fragment).

is just getting the above code, <%@page, <%@taglib and all injected into the source at the point of the <c:import or <jsp:include. I'm fairly new to jsps so I'm not really sure how to trouble shoot this issue...

I'm using jboss and looking in my working directory the pagefragment.jspf is not being translated (tried it as a .jspf and a .jsp not that that should make a difference to my knowledge...).

Thanks much for any help/insight!
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JSP include action will run the included page as separate JSP and merge the results at run time.
In order to use it, you have to insure that the page you are including is a full JSP with a .jsp extension.
In other words, the included page would have to be able to run as a standalone JSP.

If you're trying do a static (compile time) include of a fragment file, use the include directive:
See this faq entry for more details and syntax:
http://faq.javaranch.com/view?IncludesActionDirective
 
c moses
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ben thanks for the reply. I believe I've attempted this as a .jsp file as well. I am indeed attempting to use the include action - I don't want the content statically included. What I can't figure out is why the include action would include the content as if it were static?

The jspf (I'll change that to jsp) I included in my initial post ought to be able to exist as a standalone jsp were it to come down to it - based on my understanding at least.
 
c moses
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I should clarify that I'm also using Spring MVC as my j2ee framework. My knowledge of either of these topics is somewhat spotty. I can't really think of a reason why the use of Spring MVC would at all impact jsp:include but perhaps there is something that I'm missing??
 
c moses
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
bugger - it'd be nice to be able to edit my last post rather then clutter things up with another one. I just looked at sun's syntax ref for jsp:include - I hadn't realized that jsp:include processes BOTH static and dynamic pages. As that is the case, why exactly would the partial file I listed in my post be identified as a static file as opposed to a dynamic file???

Is one unable to have a dynamic relatively referenced jsp using the include tag? I'm guessing I'm just missing something painfully obvious here...

Thanks again!
 
Sheriff
Posts: 67747
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

Originally posted by c moses:
bugger - it'd be nice to be able to edit my last post rather then clutter things up with another one.



Click
 
Bear Bibeault
Sheriff
Posts: 67747
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
I include/import JSP all the time. Are you saying that it still didn't work when you changed the file type to .jsp?

.jspf should only be used for static includes.
 
reply
    Bookmark Topic Watch Topic
  • New Topic