• 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

problem with fileUpload

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i m using the commons file upload with jsp...(http://commons.apache.org/fileupload/)

My form is : -

I m able to retrieve the details using this code...

How do i use the "item" object in the else part(not a form field)

to point to a FileItem(org.apache.commons.fileupload.FileItem)

or particularly how do i use to store it to a database blob???

If i use another code for retrieving into FileItem i m getting exceptions........
DeferredFileOutputStream (probably at the line List /* FileItem */ items = upload.parseRequest(request);)

The code is

Thanks
Pradyut

 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.

 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get an InputStream from it and save it in DB using PreparedStatement#setBinaryStream().

After all it look like that your problem is JDBC related rather than FileUpload related.

That said, is that code written in a JSP or a Servlet? To start, the code doesn't look good. Java code belongs in a Servlet and HTML belongs in a JSP.
 
Pradyut Bhattacharya
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.



when i do so(click edit buttton) the editor is filled with (&)lt and (&)gt..

original message should always be stored and any modification should be done on the presentation layer....

thats a bug for javaranch.... sorry there....
 
Pradyut Bhattacharya
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bauke Scholtz wrote:Get an InputStream from it and save it in DB using PreparedStatement#setBinaryStream().

After all it look like that your problem is JDBC related rather than FileUpload related.

That said, is that code written in a JSP or a Servlet? To start, the code doesn't look good. Java code belongs in a Servlet and HTML belongs in a JSP.



Yes i have done that......
Java code belongs in a Servlet and HTML belongs in a JSP.
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Pradyut Bhattacharya wrote:
when i do so(click edit buttton) the editor is filled with (&)lt and (&)gt..

original message should always be stored and any modification should be done on the presentation layer....

thats a bug for javaranch....


That's not a bug, and it works fine. Perhaps you are not familiar with HTML entities. Have you tried editing your post to see what happens?
 
Pradyut Bhattacharya
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:

Pradyut Bhattacharya wrote:
when i do so(click edit buttton) the editor is filled with (&)lt and (&)gt..

original message should always be stored and any modification should be done on the presentation layer....

thats a bug for javaranch....


That's not a bug, and it works fine. Perhaps you are not familiar with HTML entities. Have you tried editing your post to see what happens?



Yes i have changed it..
but still it was showing lt and gt and not < or >
that was what i was saying....
well may be nothing to worry for you guys....
 
Pradyut Bhattacharya
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bauke Scholtz wrote:Get an InputStream from it and save it in DB using PreparedStatement#setBinaryStream().

After all it look like that your problem is JDBC related rather than FileUpload related.

That said, is that code written in a JSP or a Servlet? To start, the code doesn't look good. Java code belongs in a Servlet and HTML belongs in a JSP.



but i do not get the file size...
using FileItem i could get that....
 
Pradyut Bhattacharya
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ben Souther wrote:FileItem has both a getInputStream method and a getSize method.



but in my second code(where i use FileItemFactory) i m getting a DeferredFileOutputStream exception....

 
Your mind is under my control .... your will is now mine .... read this tiny ad
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic