aspose file tools*
The moose likes JSP and the fly likes jsp:include/c:import acting like include directive? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:include/c:import acting like include directive?" Watch "jsp:include/c:import acting like include directive?" New topic
Author

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

c moses
Greenhorn

Joined: Feb 10, 2005
Posts: 16
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!
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
c moses
Greenhorn

Joined: Feb 10, 2005
Posts: 16
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

Joined: Feb 10, 2005
Posts: 16
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

Joined: Feb 10, 2005
Posts: 16
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!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp:include/c:import acting like include directive?