Tag: httpconnection

在Java ME中查找应用程序模式,是否空闲

我想在应用程序处于空闲模式时使用HTTP连接发送存储的RMS数据。 因此,如果用户当时没有对应用程序执行任何操作,我的线程将调用RMS数据并将其发送到服务器。 对于此要求,如何确定应用程序处于活动模式还是空闲模式?

如何在J2ME中使用HTTP范围头?

是否可以在HTTP中使用带有HTTP GET请求的范围标头? 如果是的话怎么样? 我只想从服务器下载具有指定字节的字节。 即如果我想从0到255下载字节。

通过java中的POST方法发送Xml字符串

我想通过POST方法将xml字符串传递给URL。 我试过下面的代码片段,但它没有返回任何内容 disableCertificateValidation(); String url = “https://..url”; //https Properties sysProps = System.getProperties(); sysProps.put(“proxySet”, “true”); sysProps.put(“proxyHost”, “1.2.3.4”); sysProps.put(“proxyPort”, “80”); Authenticator authenticator = new Authenticator() { public PasswordAuthentication getPasswordAuthentication() { return (new PasswordAuthentication(“userid”, “password”.toCharArray())); } }; Authenticator.setDefault(authenticator); String xml = —xml string; URL urll; HttpURLConnection connection = null; try { // Create connection urll = new URL(url); […]

android – 上传文件时发送参数

我有这段代码http://pastebin.com/VrMNuxcv ,它成功地从我的android上传文件到服务器上。 但是,我想能够发送几个字符串参数。 如果可能的话,请你告诉我,在那段代码中我需要做什么呢?如何? 谢谢Andreas

什么是apache中的SchemeRegistry以及何时应该使用它?

Apache HTTPClient包含SchemeRegistry类(org.apache.http.conn.scheme.SchemeRegistry) 什么是Scheme Registry? 什么时候可以使用? 如果我使用如下所示的方案注册表,它会产生什么影响 SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme(WEBSERVICE_URI_SCHEME, 80 ,PlainSocketFactory.getSocketFactory())); PoolingClientConnectionManager wsConnManager = new PoolingClientConnectionManager (registry);

连接到servlet的问题来自Android客户端

我正在尝试连接到Servlet(Tomcat localhost)。 这是我的代码。 ServletTest.java (客户端) public class ServletTest extends Activity { private static final String TAG = “Test”; /** Called when the activity is first created. */ protected static EditText username; protected static EditText password; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); username = (EditText)findViewById(R.id.username); Button goButton = (Button)findViewById(R.id.connect); goButton.setOnClickListener(mGoListener); } private OnClickListener mGoListener […]

在android中无法使用httpconnection连接

我正在使用android 2.3.3,我已经制作了一个工作得很好的rss阅读器,然后我将那个简单的rss阅读器的代码集成到另一个活动中,只需复制粘贴它,没有错误。 问题是当我在我的模拟器上运行应用程序时,它给我连接exception的错误。 然后我通过在try block中的每行之后放置toast来解决问题是在httpconnection.connect(); 线。 我已经在android清单中添加了权限,而我的logcat发出了javaio exception:error connecting的警告javaio exception:error connecting 。 try { HttpURLConnection httpURLConnection = (HttpURLConnection) connection; //Toast.makeText(this, “urlconnection passed”, Toast.LENGTH_SHORT).show(); httpURLConnection.setAllowUserInteraction(false); httpURLConnection.setInstanceFollowRedirects(true); //Toast.makeText(this, “setting response method”, Toast.LENGTH_SHORT).show(); httpURLConnection.setRequestMethod(“GET”); //Toast.makeText(this, “connecting”, Toast.LENGTH_SHORT).show(); httpURLConnection.connect(); Toast.makeText(this, “on response code”, Toast.LENGTH_SHORT).show(); response = httpURLConnection.getResponseCode(); //Toast.makeText(this, “response code passed”, Toast.LENGTH_SHORT).show(); if (response == HttpURLConnection.HTTP_OK) { //Toast.makeText(this, “OK”, […]

Java:HTTP连接创建的等待连接线程持续很长时间

我有一个服务器端代码,用于检查SOAP服务是否已启动。 代码如下: String response = “”; while (response.length() == 0) { try { final URL url = new URL(“DummySoapServiceURL”); final HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection(); InputStream inputStream = null; try { httpConnection.setRequestMethod(“GET”); inputStream = httpConnection.getInputStream(); final byte[] buffer = new byte[BUFFER_SIZE]; while (inputStream.read(buffer, 0, BUFFER_SIZE) != -1) { response = new String(buffer); } } finally […]

连接错误:“org.jsoup.UnsupportedMimeTypeException:未处理的内容类型”

当我尝试打开一个用jsoup解析的链接时,我收到一个错误。 连接命令: Document doc = Jsoup.connect(“http://www.rfi.ro/podcast/emisiune/174/feed.xml”) .timeout(10 * 1000).get(); 抛出的错误: Exception in thread “main” org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml. Mimetype=application/rss+xml; charset=utf-8, URL=http://www.rfi.ro/podcast/emisiune/174/feed.xml at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:453) at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:410) at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:164) at org.jsoup.helper.HttpConnection.get(HttpConnection.java:153) at podcast.Pods.main(Pods.java:41)

如何以编程方式测试HTTP连接?

使用Java,我如何测试URL是否可联系,并返回有效的响应? http://stackoverflow.com/about