• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Enabling netscape to display xml+xsl IN DISGUISE of html.

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
I hv written a servlet which shd throw an html BY PROCESSING xml+xsl as follows.
import org.xml.sax.SAXException;
import com.sun.xml.tree.*;
import com.jclark.xsl.dom.Transform;
import com.jclark.xsl.dom.TransformEngine;
import com.jclark.xsl.dom.TransformException;
import com.jclark.xsl.dom.XSLTransformEngine;
import org.xml.sax.InputSource;
import java.io.*;
import javax.servlet.http.*;
import javax.servlet.*;
public class AccountDemo extends HttpServlet
{
public void doGet(HttpServletRequest rq,HttpServletResponse rs)throws ServletException,IOException
{
try
{
System.out.println("hello");
rs.setContentType("text/html");
PrintWriter p=rs.getWriter();
System.out.println("hello1");
XmlDocument result = new XmlDocument();
System.out.println("hello2");
new XSLTransformEngine()
.createTransform(XmlDocument.createXmlDocument (new InputSource( new FileInputStream("http://localhost:8082/servlet/account.xsl") ), false) )
.transform(XmlDocument.createXmlDocument(new FileInputStream("http://localhost:8082/servlet/account.xml"),false), result);
System.out.println("hello3");
OutputStream out = new FileOutputStream("account1.html");
System.out.println("hello4");
result.write(out);
out.close();
}
catch(Exception e){}
}
}
I am running this prog thru TOMCAT on port 8082.But the servlet is processed upto "hello2" only.
It means either it is not accessing the file account.xml& xsl FROM THE WEB-INF/CLASSES dir where servlet is resideing.I hv also tried putting the xml+xsl in ROOT.But still it is not processed.
Can anyone help me solving this.Its very important for me as this will save me creating separate XSL for netscape as servlet will throw an HTML which can be viewed thru netscape also.
By,
Manish
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I don't know if this will help you out or not but localhost:8082 isn't an actual address to where the file so it wouldn't work.
You'd have to go: "C:\\whatever\\filename.xml"
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Manish,
I think Geek provided a good pointer to solve your case. You have to use the getResourceAsStream API to read your files.
Cheers
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic