Solved

XML

Posted on 2004-04-21
7
249 Views
Last Modified: 2010-04-01
Hi Experts,

I have XML file and XSLT(formats CSV file) that are ready for use.
How to make in JSP to write this file to temp directory and open using Internet Explorer ?

Thank you.
0
Comment
Question by:fpoyavo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10883278
How to make write what???

do you want to apply the XSL to XML and get the out put a file or browser????
0
 
LVL 1

Author Comment

by:fpoyavo
ID: 10883583
Yep. Write transformed CSV file to temp dir and then open it from there via Internet Explorer (this is all has to be done within JSP)

i KNOW you are the best. Thank you.
0
 
LVL 19

Accepted Solution

by:
Kuldeepchaturvedi earned 500 total points
ID: 10883994
try
      {
      tFactory = TransformerFactory.newInstance();
      transformer = tFactory.newTransformer(new StreamSource(new File(your xsl file));
      StringWriter sw = new StringWriter();
      transformer.transform(new StreamSource(new File(your xml file)),
                          new StreamResult(sw));

            System.out.println("transformed");
            out.print(sw.toString()); // this will send the data to the Browser directly..
      }catch(Exception e)
      {
            e.printStackTrace();
            out.print("Got errors transforming");
      }

Now in here I am sending the out put of transformation directly to the browser...
you can direct to a file just by changing
line
transformer.transform(new StreamSource(new File(your xml file)),
                          new StreamResult(new File(your destination file));
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:fpoyavo
ID: 10884514
Thanks man I will try it.
0
 
LVL 1

Author Comment

by:fpoyavo
ID: 10884593
One question. If I run this JSP on Linux and need to open it as Excel file how exactly it ca ne accomplished ?
I assume this code will just print it in browser nto open it as Excel file. Right ? May be I am missing something ?
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10884626
you will have to set your content type to application/excel by doing

response.setContentType("application/excel");
0
 
LVL 1

Author Comment

by:fpoyavo
ID: 10884796
kULDEEP,

Would you please tell me where and how to use it ?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article outlines some of the reasons why an email message gets flagged as spam on a recipient's end.
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question