Java+xml Chinese Problem Solving method

Source: Internet
Author: User
xml| Solution | problem | Chinese import javax.xml.transform.TransformerFactory;
Import javax.xml.transform.*;
Import Javax.xml.transform.stream.StreamSource;
Import Javax.xml.transform.stream.StreamResult;
Import javax.xml.transform.TransformerException;
Import javax.xml.transform.TransformerConfigurationException;

Import Java.io.FileOutputStream;
Import java.io.FileNotFoundException;
Import java.io.IOException;
Import java.io.*;

Import javax.servlet.*;
Import javax.servlet.http.*;
Import Javax.servlet.http.HttpServlet;

/**
* Title:test
* Description:case Study
* Copyright:copyright (c) 2001
* Company:
* @author Tony Chen
* @version 1.0
*/

public class Test extends HttpServlet {
private static final String Content_Type = "text/html";
/**initialize Global variables*/
public void init (ServletConfig config) throws servletexception {
Super.init (config);
}
/**process the HTTP get request*/
public void doget (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException {
try{

Transformerfactory tfactory = Transformerfactory.newinstance ();


Transformer Transformer =
Tfactory.newtransformer (New Streamsource ("c:/resin/jworkflow/xsl/xxx.xsl"));
Transformer.setoutputproperty ("Encoding", "gb2312");
Transformer.transform (
New Streamsource (New File ("C:/resin/jworkflow/web-inf/classes/xml/yyy.xml")),
New Streamresult (Response.getoutputstream ()));
}
catch (Exception e) {e.printstacktrace ();}
}
/**clean up resources*/
public void Destroy () {
}
}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.