wood burning stoves 2.0*
The moose likes Struts and the fly likes File Upload using html:file tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "File Upload using html:file tag" Watch "File Upload using html:file tag" New topic

File Upload using html:file tag

Dhaval Shah
Ranch Hand

Joined: Jun 10, 2005
Posts: 56
i'm working with struts and hibernate ,i'm getting an error of type mismatch with form bean.
The Form beam has a property as datatype FormFile and my DO has the property of BLOB . i have converted the FormFile into Blob while setting into DO

FormFile ff = stepForm.getInputExampleLocation();
stepDO.setInputExampleLocation(Hibernate.createBlob (ff.getInputStream()));

In JSP:<html:file property="inputExampleLocation" />

now when i want to save in database it give error "Cannot invoke com.alas.docport.web.interview.step.StepForm.setInputExampleLocation - argument type mismatch"...

any idea what can be the problem .

Thank you,

Thanks and Regards,<br />Dhaval Shah<br />SCJP 1.4<br />SCWCD 1.4
Rusty Smythe
Ranch Hand

Joined: Aug 09, 2006
Posts: 93
So you tried:

stepDO.setInputExampleLocation(Hibernate.createBlob (ff.getInputStream()));

but you got:

setInputExampleLocation - argument type mismatch

Dhaval Shah
Ranch Hand

Joined: Jun 10, 2005
Posts: 56
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not insert: [com.alas.docport.common.data.StepDO]; uncategorized SQLException for SQL [insert into DP_STEP (STATUS, NAME, START_TIME, END_TIME, OWNER_ID, STEP_DURATION, PRODUCT_TYPE, STEP_DESCRIPTION, COMPLEXITY, CONTROL_RISK_TYPE, CONTROL_RISK_LEVEL, ACTOR_SENDER_TYPE, ACTOR_SENDER, INP_DATA_TRANSFER_NAME, INP_DATA_TRANSFER_LOCATION, INP_TRANSFER_LOCATION_TYPE, INP_DATA_FORMAT_TYPE, INP_EXAMPLE_LOCATION, ACTOR_RECEIVER_TYPE, ACTOR_RECEIVER, OP_DATA_TRANSFER_NAME, OP_DATA_TRANSFER_LOCATION, OP_TRANSFER_LOCATION_TYPE, OP_DATA_FORMAT_TYPE, OP_EXAMPLE_LOCATION, BIND_ID, VERSION, CREATED_BY, CREATED_DATE, DELETE_STATUS, LAST_UPDATED_BY, LAST_UPDATED_DATE, STEP_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; SQL state [null]; error code [17090]; operation not allowed: streams type cannot be used in batching; nested exception is java.sql.SQLException: operation not allowed: streams type cannot be used in batching

This is the error i'm getting while saving into database. is there some way we can convert the FormFile into Blob ..or some other way to upload the file

Thank you for replying .
I agree. Here's the link: http://aspose.com/file-tools
subject: File Upload using html:file tag
Similar Threads
Beanutils.populate error with file upload control
File Upload using Struts
file miss match error in struts 1
Exception in populating FormFile
could not setThe value in html:file