Solved

XML

Posted on 2004-04-21
7
246 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
  • 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

816 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now