Interaction between flash and JSP

Source: Internet
Author: User

Interaction between flash and JSP
The Flash path will certainly encounter certain bottlenecks. Sometimes flash is just an External table, and it is true that we must provide some background support for flash. Now there are many background programs. Here I select JSP. Now let's talk about the most basic HTTP-based data transmission methods, get and post. In JSP, the background service program analyzes and extracts environment variables from the URL in the get method. Post is a standard input to pass variable values. The get method imposes certain character limitations on the variables passed in the URL, while the POST method does not. Therefore, when you decide to use that method to transmit your data, you must clearly consider this. Well, let's talk about how to send variables through the get method. In flash, you can have many methods and classes that support this transmission protocol. The simplest is geturl. Passed through URL, for example: _ root. geturl ("test. jsp? Num = 123 "," get "); then num = 123 is passed to test. jsp. In the JSP file, you only need to obtain this string through request. getparamenter ("num.
Similarly, Macromedia Flash supports importing external data, such as the load, loadvariables, and loadvariablesnum methods. You may need to send an ID, and then return a data to flash after a certain logic operation in the background. Then you can use the above method.
In many cases, we often do not rely on arrays or environment variables to organize our data structures. We will select XML. In flash, organize the data to be sent into an XML Object and post it to the background service program. We can use XML. Send XML. sendandload for sending, and get it in JSP through resquest. getinputstream. Then we can use SAX or Dom to parse it and perform further operations.
In ActionScript 2.0, Macromedia adds the loadvars class. Using the loadvars class, we can perform operations similar to form submission, such as loadvars. Send () and loadvars. sendandload () methods. The editing in JSP is the same as that in common accepted forms. Is it very friendly?
This article mainly introduces an idea. Let's continue exploring it.
Finally, we need to mention some problems encountered in applications: 1. cache problems. Because the data returned from the first request is stored in the browser cache, if the same request is sent for the second time, the data imported from flash remains unchanged, therefore, the URLs of each request must be different. The simplest is to add a random number. Example: "test. jsp? Num = 123 & R = "add random (10) 2. Talk about Chinese, which is really a hassle for Flash developers. However, Java has good Unicode capabilities, which is one reason I chose it. The JSP document must include: <% @ page contenttype = "text/html; charset = UTF-8" %> and request. setcharacterencoding ("UTF-8"); nothing else.

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.