on 09-02-2004 4:30 AM
Dear all,
I am making a file upload function and the iView is developed using JSPDynPage approach.
The jsp page is very simple with a fileUpload component and a button to submit the request. And then in the JSPDynPage, the onUpload event is captured and I try to get the uploaded file content here.
However, I find that the HttpServletRequest.InputStream is already read to the end before the onUpload event, making it impossible to get the uploaded file content.
I try to monitor the InputStream at the PageProcessorComponent.doContent() function and the InputStream is fine before going into it. Somehow in the JSPDynPage approach something has processed the InputStream of the request and make me not able to read it to get the uploaded file content.
How can I solve this problem? Is there any other way to do file upload in JSPDynPage approach?
Thanks.
Devin
Hi Devin,
this should be straight forward, with some small things to consider:
Do you have set the encoding type to "mutipart/form-data" within the surrounding hbj:form?
<hbj:form id="myFormId" encodingType="multipart/form-data"> ...
If your upload button has set onClick="click", your method within your JSPDynPage could/should look somewhat like this:
public void onClick(Event event) throws PageException {
IFileParam fileParam = ((FileUpload) getComponentByName(FILE_UPLOAD_COMPONENT)).getFile();
try {
InputStream is = new FileInputStream(fileParam.getFile());
// ... do something with this stream ...
} catch (FileNotFoundException fnfe) {
// ...
}
}
Hope this helps
Detlev
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.