cancel
Showing results for 
Search instead for 
Did you mean: 

File Upload Problem using JSPDynPage in EP5 (PDK 5.0.6)

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

detlev_beutner
Active Contributor
0 Kudos

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