import tag for dynamic content
Does anyone know how to use the import tag to access dynamic content from the current context?
I naively thought this would do it...
<c:set var="url" value="/x/y/z"/>
<c:import url="${url}" var="xml" />
or
<c:set var="url" value="x/y/z"/>
<c:import url="${url}" var="xml" />
Where /x/y/z is a (context)relative path that my application maps to a servlet. However this doesn't seem to work because the import tag doesn't expand the url and make a request. It does, to be honest, what it's name suggests it should and just tries to import the content statically from the given path.
Actually I am trying to import xml for parsing here, but it seems that the xml parse tag only works upon a document in some scope and not against a URL. So I appear to be a bit stuck.
I found this...
<c:set var="xmlURL" value="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/x/y/z"/>
<c:import url="${xmlURL}" var="xml" />
and it works. But I cannot believe this is the right way to it.
TIA,
Paul B.