Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

XML

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
fpoyavo
Asked:
fpoyavo
  • 4
  • 3
1 Solution
 
KuldeepchaturvediCommented:
How to make write what???

do you want to apply the XSL to XML and get the out put a file or browser????
0
 
fpoyavoAuthor Commented:
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
 
KuldeepchaturvediCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
fpoyavoAuthor Commented:
Thanks man I will try it.
0
 
fpoyavoAuthor Commented:
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
 
KuldeepchaturvediCommented:
you will have to set your content type to application/excel by doing

response.setContentType("application/excel");
0
 
fpoyavoAuthor Commented:
kULDEEP,

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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now