Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Eclipse Collections Categorically: Level up your programming game
this week in the
Open Source Projects
forum!
senol ozer
Greenhorn
+ Follow
news
2
Posts
1
Threads
since Nov 16, 2011
Merit badge:
grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads
Recent posts by senol ozer
How to display all headers of multipart request?
Thanks for your reply!
I tried your method but it display only the value of the part. For my request example, it display only
11:35:23,770 INFO [STDOUT] ************************* 11:35:23,770 INFO [STDOUT] part : 1 11:35:23,770 INFO [STDOUT] Value1 11:35:23,770 INFO [STDOUT] ************************* 11:35:23,770 INFO [STDOUT] part : 2 11:35:23,770 INFO [STDOUT] Value2
Tere is my code:
boolean isMultipart = ServletFileUpload.isMultipartContent(request); if (isMultipart) { // Create a factory for disk-based file items FileItemFactory factory = new DiskFileItemFactory(); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); try { @SuppressWarnings("unchecked") FileItemIterator fileItemIterator = upload .getItemIterator(request); int i = 0; while (fileItemIterator.hasNext()) { FileItemStream fileItemStream = fileItemIterator.next(); System.out.println("*************************"); System.out.println("part : " + ++i); InputStream input = fileItemStream.openStream(); BufferedReader buffer = new BufferedReader( new InputStreamReader(input)); String ligne = null; while ((ligne = buffer.readLine()) != null) { System.out.println(ligne); } } } catch (FileUploadException e) { e.printStackTrace(); } }
show more
13 years ago
Other Open Source Projects
How to display all headers of multipart request?
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:
--GWqdHAxkdeIb8vSZKRRMInQ23WH77j Content-Disposition: form-data; name="identifiant" Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit Content-ID: contentId1 Value1 --GWqdHAxkdeIb8vSZKRRMInQ23WH77j Content-Disposition: form-data; name="sessionID" Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit Content-ID: contentId2 value2
Here is my code:
boolean isMultipart = ServletFileUpload.isMultipartContent(request); if (isMultipart) { // Create a factory for disk-based file items FileItemFactory factory = new DiskFileItemFactory(); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); // Parse the request try { @SuppressWarnings("unchecked") List<FileItem> items = upload.parseRequest(request); // Process the uploaded items Iterator<FileItem> iter = items.iterator(); int i = 0; while (iter.hasNext()) { System.out.println("*************************"); System.out.println("part : " + ++i); System.out.println("*************************"); FileItem item = iter.next(); System.out.println("getFieldName : " + item.getFieldName()); System.out.println("getName : " + item.getName()); System.out.println("getString : " + item.getString()); System.out.println("toString : " + item.toString()); if (item.isFormField()) { // processFormField(item); } else { // processUploadedFile(item); } } } catch (FileUploadException e) { e.printStackTrace(); } }
I can't display my "content-id" field.
Can you help me please?
show more
13 years ago
Other Open Source Projects