Unity3D and JSP TomCat server to transmit data and files (1) create a Java Server

Source: Internet
Author: User

Unity3D and JSP TomCat server to transmit data and files (1) create a Java Server

Because I did not pay for it yesterday, click Edit directly. The result is overwritten by second... As a result, I write it again now.

I spent more than half a year, not for other reasons. It was because I found my internship and was busy. I really didn't have time. However, I was recently working on this Unity upload function module, I have found a lot of information on the Internet and have not been able to upload or download files. As a result, I studied it myself. It happened that someone on CSDN had sent a private message to me, saying that I wrote well and could help people, simply put, I will share my findings with you.

The tools I use include:
MyEclipse
TomCat7
Unity3D 5.1.0f3

Well, let's talk about it in a few minutes and go straight to the topic.
To ensure that Unity can upload files, we need to create a Java Server first, so we should first open MyEclipse

Create a Java Web project

Enter the project name

This is all the engineering documents.

Right-click the Src folder and place the source code here.

New package

Pack name I used to useCom. + my English name. + class types in the folder

Right-click the package

Create a Servlet to process the form

Name the Servlet, and only the doGet and doPost methods are retained.
Click Next

Modify the ing Url

Then clear the code we don't need

In the same way, we create another Servlet

After the modification is complete, find the bottom of the project file, there is an index. jsp
This is our homepage. Double-click it to edit the first line.
Modify encoding format UTF-8

Then, go to the bottom of the file, within the body, that is, within the visible range of our webpage,

Add form

Then return to our servlet and delete unnecessary requests.
Then, print your method name to the console in each method.


Now, the basic operations on the server have been set up.
Next, we will deploy our project file to our Server TomCat.
Click the button pointed by the mouse in the figure to bring up such a window.
Click Add.

If TomCat exists in the computer, you can configure it in MyEclipse. If not, you can use the TomCat 6 that comes with MyEclipse.
If you configure TomCat, you won't ask du Niang. He explained it better than me.
Here I use Tomcat 7

After the selection is successful, we can see that TomCat already exists under the Server. Click him.
Click Redeploy where my mouse is located, that is, deploy the project to the TomCat folder.

After deployment, we can run TomCat.

After running, it is very important to mark it on the console. This is the TomCat port number.
You can ask du Niang about how to modify the port number. If the port number is occupied, TomCat may fail to start.
Then, the default port number is 8080.

With the port number, we also need to know our own IP address.
So we can open the CMD console and enter ipconfig
IPv4 address is the Server IP address we need

With the port number and IP address, we can open the browser.
Enter:
Http: // + IP: + port number/+ your project name/
In this way, you can automatically jump to the home page of your project, that is, the index. jsp We edited.
You can set the homepage by yourself. For more information, see du Niang.

Click Finish in the first form, or fill in something and then click.
The address bar shows all the information we entered.
In this way, we can use the Unity WWW class for access.

Then we use our doPost method. This method is safer than the get method, and the address bar only contains the mapped URL.

Finally, go back to our MyEclipse and check whether all the methods in the console have their names output?

OK. We will end the first sharing. Remember to redeploy the project file or code once it is modified. When you do not need a server, remember to shut down the server.

All downloaded files are written. Thank you for your support.

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.