Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

initialize FormFile struts upload

843840Aug 14 2007 — edited Aug 16 2007
I posted another topic about collection having a NullPointerException. I tried to fix the FormFile by getting info from collections. it doesn't work by having -
private FormFile sheet = new FormFile(); 
- doesn't work
private FormFile sheet = null; 
- I have this set up.

I check the validation of this -
 if (getSheet() == null || getSheet().getFileSize() < 1) {
            errors.add("type", new ActionMessage("errors.sheetnull"));
            String contentType = getSheet().getContentType();
            if (!( contentType.equals("application/pdf") || contentType.equals("text/plain") || contentType.equals("image/jpeg")
            || contentType.equals("image/gif") || contentType.equals("image/png"))) {
                errors.add("sheet", new ActionMessage("errors.sheet"));
            }
I have a string for the search engine, and when I submit, it returns the NullPointerException, although the upload formfile is for adding a document. Both functions are in a same form. Any suggestions? I might have to make a separate form for each function. Just want to know what's a right code practice or a solution to this.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 13 2007
Added on Aug 14 2007
6 comments
411 views