• 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
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

problem with fileUpload

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FileItem has both a getInputStream method and a getSize method.
 
Pradyut Bhattacharya
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....

 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic