• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

How to save request body without headers to file

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i do this



but i get this

how to remove the headers ,just get the file ?
thanks!
 
Sheriff
Posts: 21758
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

It appears you have a multipart/form-data request. You shouldn't read those directly from the input stream, you should use request.getParts() or request.getPart("aa") instead.

If you get a ServletException that indicates you do not have a valid multipart/form-data request, you should check the sender of the request - it's then not sending properly formatted requests.
 
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And it looks like you're uploading a Windows executable file, so I would advise against storing it in a file whose name ends in ".txt".
 
wu ma
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote:Welcome to the Ranch!

It appears you have a multipart/form-data request. You shouldn't read those directly from the input stream, you should use request.getParts() or request.getPart("aa") instead.

If you get a ServletException that indicates you do not have a valid multipart/form-data request, you should check the sender of the request - it's then not sending properly formatted requests.



thanks ,i get it.
 
wu ma
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:And it looks like you're uploading a Windows executable file, so I would advise against storing it in a file whose name ends in ".txt".


i want to see what the request`s inputstream have, so i save as ".txt".
now i konw how to get the file . and thanks.
 
Paul Clapham
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

wu ma wrote:i want to see what the request`s inputstream have, so i save as ".txt".



It's not a good idea to use a text file to investigate something which isn't text. Also, it looks like you can get the client's file name from the headers too.
 
wu ma
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:

wu ma wrote:i want to see what the request`s inputstream have, so i save as ".txt".



It's not a good idea to use a text file to investigate something which isn't text. Also, it looks like you can get the client's file name from the headers too.



firstly , when i get the request.inputstream `s content ,save as a ".exe" file. i click it ,but it does not work,so i want to see the file`s content,then i do this.

and i agree that it is not a good idea.  (#^.^#)
 
 
Saloon Keeper
Posts: 10307
217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you're expecting the client to upload a .exe file? Why do you want them to do that?

And executable files are binary, so you wouldn't be able to read their contents with a text editor. What do you expect to see when you open it in a text editor?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!