title: using xslt in jsp
body: <p>I want to apply xslt to my xml query results, but I keep receiving errors. I am working on Tomcat and my java code includes:</p>
  
  <pre><code>String ret="";
  String xsltstylesheet = "https://dl.dropbox.com/x/xsltstylesheet.xsl";            
  QueryExecution qExec = QueryExecutionFactory.create(query, model) ;
  ret += ResultSetFormatter.asXMLString(qExec.execSelect(), xsltstylesheet);   
  qExec.close() ;    
  return ret;
  </code></pre>
  
  <p>so having formatted my results as <em>XMLString</em>, I've been trying to produce html from it by using <strong>1-transform</strong> and <strong>2-jstl</strong> in my jsp but neither of cases is working:</p>
  
  <pre><code>&lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;?xml-stylesheet type="text/xsl" href="https://dl.dropbox.com/x/xsltstylesheet.xsl"?&gt;
  &lt;%
     String search=request.getParameter("user");
     if(search==null) search="logic";
     String result=search;  
     try{
        ProjectMain pm=new ProjectMain();
        result=pm.different(search);
     }
  
  //-case 1
     Source source = new StreamSource(${result}); // ?syntax error, misplaced constructor
     Source xsl = "https://dl.dropbox.com/u/84745393/xsltstylesheet.xsl";
     Result table = new StreamResult(System.out);  
     StreamSource xsltSource = new StreamSource(new StringReader(xsl)); 
     Transformer t = TransformerFactory.newInstance().newTransformer(xsl);  
     t.transform(xsl, table);    
  
  //-Or case 2
     &lt; c:import url="${result}" var="xmldocument"/&gt;//Multiple annotations found at this line, Syntax error, insert";" /on token"&gt;"/ on token "import"...
     &lt; c:import url="https://dl.dropbox.com/x/xsltstylesheet.xsl" var="xslt"/&gt; 
     &lt; x:transform xml="${xmldocument}" xslt="${xslt}"/&gt;    
  
     out.println(result);
  %&gt;  
  </code></pre>
  
  <p>I guess my problem is that <em>transform</em> needs it's input in terms of StreamSource but mine is not. And I don't think I should write every instance of my query result in file to be able to convert it to html later. </p>
  
  <p>What do people usually do? I don't know how to fix it.</p>