Solved

XML

Posted on 2004-04-21
7
243 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

21 Experts available now in Live!

Get 1:1 Help Now