urlconnection

Passing custom Objects from applet to servlet

天大地大妈咪最大 提交于 2020-01-05 05:49:05
问题 I have a servlet and i want to pass through UrlConnection some objects. When I tested it, it worked fine. When I passed Java native objects ( String , File ..). But when I try to pass my own Object (instance of my own Class), Object is sent into Servlet correctly via ObjectOutputStream but when I wanted to restore object in servlet side it doesn't work. it throws exceptions that My class was not found. I have MyObject class in project with applet where is loaded and sent to servlet and then i

Session cookie not send back by client using URLConnection in windows with JRE 1.7

余生颓废 提交于 2020-01-04 08:05:10
问题 We have an application that is deploied using Java Web Start. It communicate with a servlet using URLConnection and managing session by Cookies (JSESSIONID). It worked well with Java 1.5 & 1.6. With Java 1.7 in windows It doesn't work anymore: cookie JSESSIONID is not send back to the server (I saw this using apache axis's HTTPMonitor). What's going wrong? Launching the same application with Java Web Start from a linux box works as expected. Version are: JRE 1.7.0_04 with Java Web Start 10.4

getContentLength doesn't work on android for FTP url

隐身守侯 提交于 2020-01-03 03:06:08
问题 Following code prints length -1 for filesize on android, but it works fine on desktop JAVA. I'm using Android 2.2. URL url1 = null; URLConnection uconn = null; try { url1 = new URL("ftp://FTPHOST/file.zip"); uconn = url1.openConnection(); uconn.setDoInput(true); int len= uconn.getContentLength(); int headersize = uconn.getHeaderFields().size(); System.out.println("******************************* "+len); } catch (Exception e) { e.printStackTrace(); } return null; Let me know if any workaround

Java ssl performance issue in connection with downloads

ぐ巨炮叔叔 提交于 2020-01-01 07:13:11
问题 i'm currently working on a small swift-client and got some hard performance issues by downloading files. After thousands of checks i localized the problem by downloading files through ssl. Normal downloads(http) works fine without any problems(or performance issues). But SSL downloads blow up my CPU ... a single core goes up to 100 % load (for a single thread) i wrote a small testclass without my entire program and can confirm my previous observations. package testDownload; import java.io

URLConnection setRequestProperty vs addRequestProperty

*爱你&永不变心* 提交于 2019-12-30 03:03:10
问题 Lets say I'm talking HTTP to a web server, and I will Accept html or text, but prefer html. In other words, the header should say (I think!) Accept: text/html, text/* I'm using Java, so I have a URLConnection. Should I use: myUrlConnction.setRequestProperty("Accept", "text/html"); myUrlConnction.addRequestProperty("Accept", "text/*"); or myUrlConnction.setRequestProperty("Accept", "text/html, text/*"); or are they equivalent??? In general, most of the third party code I see doesn't seem to

Reading from a URL Connection Java

只谈情不闲聊 提交于 2019-12-29 08:57:21
问题 I'm trying to read html code from a URL Connection. In one case the html file I'm trying to read includes 5 line breaks before the actual doc type declaration. In this case the input reader throws an exception for EOF. URL pageUrl = new URL( "http://www.nytimes.com/2011/03/15/sports/basketball/15nbaround.html" ); URLConnection getConn = pageUrl.openConnection(); getConn.connect(); DataInputStream dis = new DataInputStream(getConn.getInputStream()); //some read method here Has anyone ran into

Equivalent of java.net.URLConnection in .NET

家住魔仙堡 提交于 2019-12-24 15:56:48
问题 Is there an equivalent of the java.net.URLConnection class in .NET. , for example the HttpWebRequest ? What else could be used? 回答1: Probably the closest is: WebRequest req = WebRequest.Create(url); // note this is IDisposable so // should be in a "using" block, or // otherwise disposed. since this will handle multiple protocols etc. But if you are meaning http - I'd use WebClient ; it is much simpler than HttpWebRequest (one of the WebRequest implementations). If all you want is to download

URLConnection doesn't work since API 10 and higher?

隐身守侯 提交于 2019-12-24 02:54:10
问题 Hey I'm having a big issue with my android App. I'm currently updating it and I switched from API 8 to API 10 and the following block of code doesn't work anymore ... URL url = new URL(PingUrl); URLConnection Conn = url.openConnection(); Conn.setConnectTimeout(4000); int Size = 2048; BufferedReader input = new BufferedReader(new InputStreamReader(Conn.getInputStream()), Size); String line = null; while ((line = input.readLine()) != null) { JSONObject jo = new JSONObject(line); String

HTC One bug? Parts of HTTP header appearing in URLConnection InputStream

試著忘記壹切 提交于 2019-12-23 15:44:42
问题 I have some code to download an XML file that has been shipping in a paid app for a few years - never had any trouble until I recently saw this happen with an HTC One. Wondering if there is something I am missing or if this should get reported somewhere. Here is example code that forces the issue: package com.lutron.davetest; import java.io.BufferedInputStream; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; import android.os.AsyncTask; import android.os.Bundle

It is possible to stop a thread that is connecting to URL with httpConnection.connect()?

雨燕双飞 提交于 2019-12-23 08:30:12
问题 i have a thread that is connecting to a url to obtaining some data. Sometimes the method httpConnection.connect(); taked too munch time to get the response, and i want to limit the loading dialog of this connection thread to 5 seg. I tryed adding timeouts into the code, but it doesn't work !! URL formattedUrl = new URL(url); URLConnection connection = formattedUrl.openConnection(); connection.setConnectTimeout(5000); connection.setReadTimeout(5000); HttpURLConnection httpConnection =