Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Servlets
Search Coderanch
Advance search
Google search
Register / Login
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
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
Servlets
file upload problem
Javed Sardar
Ranch Hand
Posts: 33
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
The following is the HTML code I am using to upload a file
<HTML> <BODY> <center> <form encoding="multipart/form-data" method='get' name = 'SubmissionForm' action="/jas/FileUpload"> <table BORDER="0" WIDTH="100%"> <tr> <td ALIGN="center"colspan="2"><b>Select a file to Upload </b><input type="File" Name="File" class = "form"></td> </tr> <tr> <td ALIGN="right"WIDTH="50%"> <input type="submit" name="Action" value="Upload"> </td> </tr> </table> </form> </center> <BODY> </html>
IN my
servlet
when I try to get request.getContentType, it is returning null.
Could anybody please suggest when am I going wrong.
Thanks and Regards,
Javed.
Arun Prasad Namasivayam
Greenhorn
Posts: 5
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You need to change the <form> attribute "encoding" to "enctype" thatz the only error i can see in the HTML.
keep smiling
arun
M.K.A. Monster
Ranch Hand
Posts: 130
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I've been using the oreilli classes, and when you look at these code there's something else interesting:
String type = null; String type1 = req.getHeader("Content-Type"); String type2 = req.getContentType(); // If one value is null, choose the other value if (type1 == null && type2 != null) { type = type2; } else if (type2 == null && type1 != null) { type = type1; } // If neither value is null, choose the longer value else if (type1 != null && type2 != null) { type = (type1.length() > type2.length() ? type1 : type2); }
A "dutch baby" is not a baby. But this tiny ad is baby sized:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
MultipartRequest cannot be resolved to a type
Array Index Out Of Bounds
Ajax javascript not recieving responseText from Struts
JSP returning old data, database was changed correctly!
Cannot get filenames
More...