Hello To Every One

I have transformed xml document using servlet now i need to know how can i transform xml document using jstl. I have found this code very often but it doesn't work with a relative or absolute url. I need to pass parameters dynamically.

<c:import var="xml" url="<%=xmlFile%>" />
<c:import var="xslt" url="<%=xsltFile%>" />
<x:transform xml="${xml}" xslt="${xslt}" />

In this code I have to pass xmlFile and xsltFile parameter dynamically and i want to make it as session variables. When i put relative url in <c: import > tag it works fine but for absolute url it does not work. Although I doesnot want to pass absolute url but relative ones, but how can i achieve that one.

E.G.

<x:transform xml="relative url for xmlfile" xslt="relative url for xslt file" />

don't mix scriptlet and jstl code (which is what you're doing).

Thanx for your answer This is my Code which works fine. But i need to pass xslt and xml path dynamically.

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
 
<html>
  <head>
 
  </head>
 
  <body>
    <form method="post">
   <c:import var="xml" url="..\\data\\192.168.1.94\\master.xml" />
<c:import var="xslt" url="..\\other\\Masterview.xsl" />
<x:transform xml="${xml}" xslt="${xslt}" />
    </form>
  </body>
</html>

But in <c:import > tag i want to put url value dynamically so when i convert that string to a variable and pass that variable into url attribute it does not work.

Like This

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
 
<html>
  <head>
 
  </head>
  <body>
   <%
   try{
   	String xmlFile="..\\data\\"+session.getAttribute("param1").toString()+"\\master.xml";
 
   	String xsltFile="..\\other\\"+session.getAttribute("param2").toString()+"\\MasterView.xsl";
 
   	
   	}catch(Exception ep){ep.printStackTrace();}
   %>
    <form method="post">
   <c:import var="xml" url="<%=xmlFile.toString()%>" />
<c:import var="xslt" url="<%=xsltFile.toString()%>" />
<x:transform xml="${xml}" xslt="${xslt}" />
    </form>
  </body>
</html>

so?
You don't need scriptlets for that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.