I'm wondering if there is any way to upload files from a java program to a website that has a simple html form.
An example could look like the one on tinypic.com or bayimg.com.
Are there any Java libraries capable of performing this? Please point me in the right direction :).
Thanks.
Mike.
HTML Form uses just HTTP POST/PUT methods to upload file to server, you don't have to work/think in this case with HTML FORM, just do HTTP Connection to script and send data in required format
Read more:
http://www.jguru.com/faq/view.jsp?EID=62798
http://www.theserverside.com/news/1365153/HttpClient-and-FileUpload
http://www.java-tips.org/other-api-tips/httpclient/how-to-use-multipart-post-method-for-uploading.html
http://www.prasannatech.net/2009/03/java-http-post-file-upload-server.html
http://www.google.cz/search?aq=f&sourceid=chrome&ie=UTF-8&q=java+http+post+upload
Related
I am working in a jsp file. I have a lot of files available in my Sharepoint intranet with link like this :
http://myIntranet.eu/my%pdf%1.pdf
I want saved the pdf in a folder in my server. This will help me then to merge all PDF.
I had already merge pdf in java, but I don't know how I can save this PDF on my server.
Can you please help me on how to do that.
If there is no web service or rest service from sharepoint to get the pdf, you can try to use an http client http://hc.apache.org/httpcomponents-client-ga/ to make request to sharpoint on java server to get the pdf file. Maybe you need authentication.
I want to upload a file to a general website.
It seems I'll have to use HTTP requests which I can obtain through http://www.fiddler2.com/.
But I'm a complete beginner in handling HTTP or webrequests. Could someone guide me into a good tutorial on HTTP requests using C++ or Java?
Most websites are in need of a login for example. Also, does a general website accept those http request to upload a file? For uploading a file to a general website it seems you will need a login handler, get the correct request to upload the file and then upload it. To get those correct requests, do I have to see what that specific site asks?
The goal is to upload a file to a general website of choice and expand from there on to more websites.
Thanks in advance!
I was trying to crawl some of website content, using jsoup and java combination. Save the relevant details to my database and doing the same activity daily.
But here is the deal, when I open the website in browser I get rendered html (with all element tags out there). The javascript part when I test it, it works just fine (the one which I'm supposed to use to extract the correct data).
But when I do a parse/get with jsoup(from Java class), only the initial website is downloaded for parsing. Meaning there are some dynamic parts of a website and I want to get that data but since they're rendered post get, asynchronously on the website I'm unable to capture it with jsoup.
Does anybody knows a way around this? Am I using the right toolset? more experienced people, I bid your advice.
You need to check before if the website you're crawling demands some of this list to show all contents:
Authentication with Login/Password
Some sort of session validation on HTTP headers
Cookies
Some sort of time delay to load all the contents (sites profuse on Javascript libraries, CSS and asyncronous data may need of this).
An specific User-Agent browser
A proxy password if, by example, you're inside a corporative network security configuration.
If anything on this list is needed, you can manage that data providing the parameters in your jsoup.connect(). Please refer the official doc.
http://jsoup.org/cookbook/input/load-document-from-url
I currently have to post HTML form to a java server like ( www.example.com/file.do ).Java server accept only HTML request. So whenever i post request with html file its work fine. But whenever i post it from php its not working ( same html file just change the extension to php). I have also try with mod-rewrite by changing php to html with .htaccess but nothing happen still not works. So i am thinking is there any difference in html form post and php form post? Or is there any other solution so i can post html form through php to java?
Thanks to all.
I think you are posting from localhost. Try to post from a live server. Hopefully this will solve your problem.
technically there is no difference.
Check whether there are some special http headers set, which are not accepted by your server, i.e.
X-Powered-By etc.
To create a POST request from a PHP script, you need to use curl; but to submit a form from the browser, it doesn't matter what the extension of the file that is rendered is.
Does anyone have an example of how to send both binary (image) and text-based data in a single servlet response? An example is returning an image and image-map all generated on the server. I was also not able to find a mixed-mode mime type to use to be able to perform this operation.
Thoughts?
Browser support for multipart responses is still pretty dicey (read here). But if you are planning to parse the response on the client side yourself there are some pretty good examples out there. The mime-type you are looking for is multipart/mixed.
You can use Data URI to embed binary objects into generated HTML.
E.g.
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4/8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot">
See also: https://serverfault.com/questions/241218/why-do-http-servers-not-send-a-single-file-back-when-possible#241224
This is not how HTTP and HTML work. A first request is made to load HTML code. This HTML code contains <img src="..."/> tags, which point to the URL of the image. A second request is then made by the browser to load the image. You can't download the HTML and the image in a single request.
Many WAP browsers supports multi-part responses, but I don't think "regular" browsers do.
Also see Browser support of multipart responses