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

Uploading Single File by Using enctype="multipart/form-data"

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a JSP page where I have to select a file Uploading after selecting a drop down value i.e. my file upload option is visible only i select a specific value from the drop down say "upload" else file upload option is invisible.

I have to process my request as a normal form request in case no file upload option is selected. and if the file is selected for upload it should be process accordingly. I have created my JSP like below:

Form 1: have all the fields including drop down., i.e normal form. if drop down value is selected "upload" then render the file upload option in 2nd form.
Form 2: having file upload field i.e. enctype="multipart/form-data" and a button.

While pressing the button in invoke a java script and check if file upload is null, if yes submit form1 i.e. form1.submit() else submit form2 i.e. form2.submit();

I am using : boolean isMultipart = FileUpload.isMultipartContent(request); check but each time it gives me the same boolean flag value is true, whether the file uploaded option is selected or not.

Kindly let me know how can i accomplish this.

Thanks
R.S.
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting!!! But i dont understand very weel you problem. I need to see part of you code (servlet).
Please check this example they make comparation diferent to you. Try it! example
 
Ravish Srivastava
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for response.

This problem is solved. The issue was <input type="submit" /> was in 2nd from and hence, it was submitting the enclosing form which was multi part. i changed to <input type=""button" /> and it solved my problem.

 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!