This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • 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
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

How to display all headers of multipart request?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!

I would like process multipart request from my servlet. For this, I use the API Apache Common FileUpload.

Here is an example of my request:


Here is my code:


I can't display my "content-id" field.

Can you help me please?
 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Think you can achieve what you want by doing the following:

Use the getItemIterator method instead of the parseRequest method.

Use the FileItemIterator returned to iterate through the FileItemStream instances.

Use the openStream method of the FileItemStream instances to read the contents.

I didn't try it yet, but that's what I can gather by reading the API.

Hope it helps!
 
senol ozer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply!

I tried your method but it display only the value of the part. For my request example, it display only


Tere is my code:
 
Clivant Yeo
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Senol,

I took a look at the api again. It seems that FileItemStream extends FileItemHeadersSupport, which means that there is a getHeaders() method available from the fileItemStream instances.

API for FileItemStream

API for FileItemHeadersSupport

I have a strong feeling that the getHeaders() method is what you are looking for.

I don't have a Java web container installed on my machine, but let me know if this works.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!