Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8646305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:46:24+00:00 2026-06-12T12:46:24+00:00

package com.yarin.android.Examples_08_01; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL;

  • 0
package com.yarin.android.Examples_08_01;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

//以Get方式上传参数
public class Activity03 extends Activity {
    private final String DEBUG_TAG = "Activity03";

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.http);
        TextView mTextView = (TextView) this.findViewById(R.id.TextView_HTTP);
        // http address "?par=abcdefg" is the argument to be posted
        String httpUrl = "http://192.168.0.100:8080/httpGet.jsp?par=test";
        // 获得的数据
        String resultData = "";
        URL url = null;
        try {
            // 构造一个URL对象
            url = new URL(httpUrl);
        } catch (MalformedURLException e) {
            Log.e(DEBUG_TAG, "MalformedURLException");
        }
        if (url != null) {
            try {
                // 使用HttpURLConnection打开连接
                HttpURLConnection urlConn = (HttpURLConnection) url
                        .openConnection();
                // 得到读取的内容(流)
                InputStreamReader in = new InputStreamReader(
                        urlConn.getInputStream());
                // 为输出创建BufferedReader
                BufferedReader buffer = new BufferedReader(in);
                String inputLine = null;
                // 使用循环来读取获得的数据
                while (((inputLine = buffer.readLine()) != null)) {
                    // 我们在每一行后面加上一个"\n"来换行
                    resultData += inputLine + "\n";
                }
                // 关闭InputStreamReader
                in.close();
                // 关闭http连接
                urlConn.disconnect();
                // 设置显示取得的内容
                if (resultData != null) {
                    mTextView.setText(resultData);
                } else {
                    mTextView.setText("读取的内容为NULL");
                }
            } catch (IOException e) {
                Log.e(DEBUG_TAG, "IOException");
            }
        } else {
            Log.e(DEBUG_TAG, "Url NULL");
        }
        Button button_Back = (Button) findViewById(R.id.Button_Back);
        /* 监听button的事件信息 */
        button_Back.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                /* 新建一个Intent对象 */
                Intent intent = new Intent();
                /* 指定intent要启动的类 */
                intent.setClass(Activity03.this, Activity01.class);
                /* 启动一个新的Activity */
                startActivity(intent);
                /* 关闭当前的Activity */
                Activity03.this.finish();
            }
        });
    }
}

For the above code, I understand how it works. It runs as an application and needs to communicate with a web server.

But I don’t know how to make a web server which could be a container of “http://192.168.0.100:8080/httpGet.jsp”.

I did some investigation.

(1) On Android phone, i-jetty, kws, atieews may help, but I failed to make them work for my purpose.

(2) On PC, tomcat is a good candidate to be as jsp container. But it provides localhost:8080 address, that means only application runs on PC could communicate with it. Am I right? How to make my Android phone to connect tomcat (runs on my PC)?

(3) Any other idea?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:46:25+00:00Added an answer on June 12, 2026 at 12:46 pm

    To make a server which can communicate with your android app you can use SOAP services or JSON. Those two are the most used ones (JSON is faster and in my opinion better to use but this can be discussed).

    Take a look on some tutorials on how to create the server side app for your android app.
    This is not an easy taski if you newer set up a server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

package com.example.application; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import org.jsoup.Jsoup; import org.jsoup.nodes.Document;
Here is my code: package com.AndroidCustomDialog; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException;
package com.Project_recording; import java.io.File; import java.io.IOException; import android.app.Activity; import android.media.MediaPlayer; import android.media.MediaRecorder; import android.os.Bundle;
package com.VRG; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import android.app.Activity; import android.content.Context; import android.media.MediaPlayer;
package com.crumbin.tabs; //java package import java.io.IOException; import java.util.ArrayList; import org.json.JSONException; import android.app.Activity; import android.app.AlertDialog;
package com.rest; import java.io.IOException; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button;
package com.login.android; import java.net.InetSocketAddress; import java.net.Socket; import java.nio.ByteBuffer; import java.nio.channels.SocketChannel; import com.login.android.R; import android.app.Activity;
MakeMissedCallActivity.java: package com.android.main; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import
This is my FragmentListArraySupport.java package com.test.methods; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.ListFragment; import android.util.Log;
here is my Code package com.example.messenger; import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.