• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

file upload using doPut()

 
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how can we upload/FTP a file to a specified location using doPut() method?

and is it better to use doPut() method for uploading a file rather than using some utilities from apache etc?

Thanks
Neeraj
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess there is no method in the Servlet API to do this. And no modern browser uses HTTP PUT for anything meaningful, so doPut() should not be used [this is what my understanding]. So i guess using apache libraries could be the good. [package org.apache.commons.upload]
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I guess there is no method in the Servlet API to do this.



There is. You can get the input stream and stream the file. The commons upload utility allows you to stream the file AND read some parameters when you do a multipart request.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
PUT is not supported by HTML forms, so if you were planning to upload files from a web browser, you can't use it.

What prompted this question? What do you hope to achieve that POST can't do?

And no modern browser uses HTTP PUT for anything meaningful


Just to be precise: HTML forms don't use PUT at all, but browsers can do useful things with PUT through the JavaScript XMLHttpRequest object.
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BTW, I think many web servers are configured not to accept PUT and DELETE Http Requests, So I think it is better to stick to POST,
If its your server and looking for good amounts of file transfers, I guess you can consider using a FTP Server/client combination instead...

HTH
 
Deepak Bala
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

BTW, I think many web servers are configured not to accept PUT and DELETE Http Requests



Does this claim have a source ? Most web servers should support the request, but probably, no one will every use them. Unless you are working with Atom publishing protocol or something like that.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I think many web servers are configured not to accept PUT and DELETE Http Requests


Most web servers should support the request, but probably, no one will every use them. Unless you are working with Atom publishing protocol or something like that.


... or RESTful web services, which make extensive use of the less common HTTP methods, and are becoming ever more popular.
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am going through a source code, where a servlet is written to process doPut Request. it is saving the file uploaded as .csv file using stream. I am not sure how that servlet is getting invoked if it can't be invoked through a browser.

can it be done through some web proxy servers by modifying the http methods?

I am not sure if it's file upload or it's supporting FTP.


Any inputs will be a great help.

Thanks
Neeraj.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Servlets do not support FTP, and proxies had better not modify any request as fundamentally as changing the method.

Even though HTML forms do not support PUT, there's no difficulty in writing a client that does - the Apache HttpClient library is an example of that.
 
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic