• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

request.getPart("name") in Tomcat 7

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I'm programming a web site.

In one page the user can upload a image (in the html I use the element <input type="file" name="flUpload"....> and in the form I add this attribute: enctype="multipart/form-data"), when the user press Send I receive the form in a servlet. In this servlet I do this:


But when I upload my web site to my Tomcat 7 server, the user can't upload images. I have got this exception:

java.lang.NullPointerException
org.apache.catalina.connector.CoyoteWriter.write(CoyoteWriter.java:184)
Interfaz.RegistroImagen.doPost(RegistroImagen.java:108)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

Where Interfaz.RegistroImagen is my servlet.

In my GlassFish server this runs OK, the user can upload images.

What can I do?

Thanks.
 
Jose Alvarez
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solved the problem. I edit the file context.xml (tomcat->conf). You need to edit it, putting the attribute allowCasualMultipartParsing="true" in the tag <Context>, and then you have: <Context allowCasualMultipartParsing="true">. Restart the server and it works.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having the same issue.I applied the fix,but it doesn't works.I am using eclipse.Following is the Exception Report I am getting.....


Please help.
 
Dushyant Shukla
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got it working.Although I am now able to upload the images into a directory on my file system but the image is not displayed on the jsp page,instead a default icon of broken image in displayed.Here is my complete code:

file_upload.jsp


ajax_file.jsp


FileName.java




DisplayImage.java


 
reply
    Bookmark Topic Watch Topic
  • New Topic