Ajax server servlet considerations

Source: Internet
Author: User

Recently, because the display speed of the Treeview control in Javascript form is too slow, I used Ajax + Yahoo UI to create a new one. After using Ajax for the first time, we finally implemented a lazy load-type classification tree. The server is a turbine action servlet that obtains the subnode information list based on the input node ID and returns the information in XML format. During the implementation process, we found that the servlet was still well written:

1. response. setcontenttype ("text/XML; charset = UTF-8") should be explicitly called to tell the client to return XML. If the settings are not enough in the generated XML template (I use the velocity template );

2. XML for client-to-server communication must be encoded in UTF-8 and the output stream of response must be set to UTF-8 encoding. If the GBK encoding client JavaScript calls Dom to process XML, a problem may occur;

Outputstreamwriter OSW = new outputstreamwriter (response. getoutputstream (), "UTF-8 ");

......

Related Article

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.