Several ways for Android to get data from the server side

Source: Internet
Author: User
Tags json sqlite database xmlns


In Android, sometimes we don't need to use the local SQLite database to provide data, more often from the network to get data, then how does Android get data from the server? There are many kinds of



1: Obtain data method based on HTTP protocol. 

2: Data acquisition method based on SAOP protocol.

3: forget-------



So our article is mainly about using the HTTP protocol to obtain server-side data, where we take the server-side technology for Java, the framework for STRUTS2, or can have a servlet, or directly from the JSP page to get data.



So, then we start the journey:



First: Write the server-side method, I used here the MVC framework is STRUTS2, the purpose is very simple, is to do a complete business project, the technology is equipped with: Android+ssh. Of course, space is limited, I am here directly with Strtus2 just.



Server side: New WebProject, choose Java EE 5.0.



In order to add STRUTS2 support to the project, we have to import some of the class libraries of Struts2, such as the following (some of the jar packages are not necessary, but we can later expand to be used, we get in first):



1:xwork-core-2.2.1.1.jar



2:struts2-core-2.2.1.1.jar



3:commons-logging-1.0.4.jar



4:freemarker-2.3.16.jar



5:ognl-3.0.jar



6:javassist-3.7.ga.jar



7:commons-ileupload.jar



8:commons-io.jar



9:json-lib-2.1-jdk15.jar processing JSON format data to use to



10:struts2-json-plugin-2.2.1.1.jar JSON plugin based on STRUTS2



The above jar package needs to be placed under the Webroot/web-inf/lib directory



Then knock down in the Web.xml file:





  






Xmlns= "Http://java.sun.com/xml/ns/javaee"



Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"



Xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee



Http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd ">



  






  



  Struts2



  



  Org.apache.struts2.dispatcher.FilterDispatcher









  Struts2



  /*









  index.jsp









Then write the Struts.xml file and place it in the Webroot/web-inf/lib directory: The following code:




  






"-//apache Software foundation//dtd Struts Configuration 2.0//en"



"Http://struts.apache.org/dtds/struts-2.0.dtd" >






  









  





  






  














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.