Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp:includes  RSS feed

 
Jim Babcock
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got two include questions for you all.

1) The following work:
<jsp:include page="../navBar.jsp" />
<%@ include file="../navBar.jsp" %>
But I'd prefer to use the "/wds/navBar.jsp" so I don't have to track all my include if I should move a file. Unfortunately, I can't make this work... any ideas? This is using tomcat 5.5

2) I've got a bunch of resources on different machines that I'd like to embed in pages on a central web site. How do I accomplish the equivalent of "<jsp:include page="../navBar.jsp" />" for a non-local resource? (ie: <jsp:include page="http://navBar.jsp" />

Thanks,

Jimbus
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'd probably have to implement your own custom tag that opens a socket, does the request itself, and then includes the response in its own response stream. This isn't a common thing, so that's probably why you don't get a standard action to do this for you like a jsp:include would. Happy coding.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) What is 'wds'? The context name? If so, you don't need it. If the file is in the root of your web app:



will do the trick. Otherwise, use whatever folder structure is under your web app root. For example, if the file is in folder xyz:



The important thing to remember is that the include path is relative to the base of the web application.

2) Use the <c:import/> tag from the JSTL.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jim Babcock:

2) I've got a bunch of resources on different machines that I'd like to embed in pages on a central web site. How do I accomplish the equivalent of "<jsp:include page="../navBar.jsp" />" for a non-local resource? (ie: <jsp:include page="http://navBar.jsp" />


As this violates the "self contained web app" principal being pushed in the servle/jsp specs since 2.3, you'll probably find very limited support, if any for doing so.

You're better off creating an ANT build script that assembles your war files from all the different components.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're better off creating an ANT build script ...


Gotta second that notion.
 
Jim Babcock
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys,

Your suggestions for the first worked like a charm... it just seems foreign to me.

For the second one, I don't have taglibs set up and I already made a bean to pull specific information from the pages for another jsp, so I just made a bean to suck back the whole thing... it works pretty snazzily.

Thanks again,

Jimbus
 
Jim Babcock
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:


As this violates the "self contained web app" principal being pushed in the servle/jsp specs since 2.3, you'll probably find very limited support, if any for doing so.

You're better off creating an ANT build script that assembles your war files from all the different components.


I'm not sure I understand... or maybe I'm not describing the situation well enough.

I want to leverage data that exists in existing dynamic web applications on other servers. Some of these are pages generated by pearl scripts, some are other technologies. I guess I want the jsp:include to behave like an iframe, which it does for jsp files on the local machine, for remote web based applications. It seems absurd that you'd want me to write a new local application for any external datasource just so I can integrate them for managerial audience.

Jimbus
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't like <c:import>?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I want the jsp:include to behave like an iframe, which it does for jsp files on the local machine


Not really. An iframe creates a sub-window and an entirely new request. The <jsp:include> directive processes its target and includes it as part of the current request and results in a single response to a single target window.

Didn't want anyone to become confused.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, it could be interesting to write such a tag.
One that works kind of like wget but only grabs the html.
It would have to prepend the base URL to any image or iframe tag src attributes.
Have the tag dump the results right to the output stream.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!