Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Open Source Projects
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Microservices Testing (Live Project)
this week in the
Spring
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
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Ron McLeod
Jeanne Boyarsky
Paul Clapham
Sheriffs:
Liutauras Vilda
Henry Wong
Devaka Cooray
Saloon Keepers:
Tim Moores
Stephan van Hulst
Tim Holloway
Al Hobbs
Carey Brown
Bartenders:
Piet Souris
Mikalai Zaikin
Himai Minh
Forum:
Other Open Source Projects
the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is
yogi maheshnath
Ranch Hand
Posts: 30
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I am using apache commons file upload and getting following error:-
the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is null
servlet
code
ServletFileUpload servletFileUpload=new ServletFileUpload(new DiskFileItemFactory()); List fileItemsList; fileItemsList = servletFileUpload.parseRequest(request); Iterator it= fileItemsList.iterator(); while(it.hasNext()) { FileItem fileItemTemp=(FileItem)it.next(); if(fileItemTemp.isFormField()) { String name1 = fileItemTemp.getFieldName(); String value = fileItemTemp.getString(); System.err.println(name1); }else { String fileName = fileItemTemp.getName(); Connection conn=null; ResultSet rs=null; Statement st=null; Access acc=new Access(); conn=acc.getConnection(); System.err.println(conn); String name=""; rs=acc.executeQuery("select * from importtable where filename='"+fileName+"' and type='"+choice+"'"); if(rs.next()) { name=rs.getString("name"); } if(choice.equals("Corporate")) { dir="Corporate"+"/"+name; }else if(choice.equals("Individual")); { dir="Individual"+"/"+name; } path=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"+"upload"+"/"+dir; File saveTo=new File(path+fileName); fileItemTemp.write(saveTo);
jsp
code
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1" contentType="text/html"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'import.jsp' starting page</title> <meta http-equiv="Content-Type" content="text/html" /> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <form name="upload" enctype="multipart/form-data" action="servlet/Importer" method="get"> <table> <tr><td> <input type="file" name="filename"> </td> <td> <input type="submit" value="Upload"></td> </tr> <tr> <td>Corporate<input type="radio" name="choice" value="Corporate"></td> <td>Individual<input type="radio" name="choice" value="Individual"></td> </tr></table> </form> </body> </html>
Thanks&Regards<br />Yogi MaheshNath
Jhon Ortiz
Greenhorn
Posts: 16
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi!
Try putting method="POST" in the form.
So long!
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Posting session variables in single JSP page
Tomcat 5.5.26 Sessions getting replicated but not working via browser
How to find method in Sturts
JSP Not Reading Arraylist
Image preview with upload
More...