Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation problem during FileUpload

 
Ajju Chawla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I've a JSP page in which user enters certain inputs and uploads a file.
These inputs I validate in the validate () method in the Form class. Now the problem is that in case a file of bigger size is uploaded, it takes lot of time to display a message to the user if one of the validation fails.
Is there some way that I validate the inputs from the screen and if everything is ok , then only proceed with file upload??

Thanks
-Aj
 
Naik Priyanks
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I would suggest is keep the file input-type disabled in ur jsp when it renders for 1st time or when validation fails.
If validation is successful then redirect to the same jsp with the input type as enabled.
You can do the conf settings in the struts-config.xml.
 
Ajju Chawla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thanks for the reply..

So what u r saying is that during the first submit
1. submit the page without the FileForm fields(disable input-type file).
2. Validate and if there is error than set Action Error.
3. Else redirect on the same page enable input-type = file, and submit on load.

The problem would come in #3. I'll loose the selected files, and it would not be nice to display the same page to the user again...

If I understood u wrong pls tell me.

-Aj
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using the validator framework you can enable client side validation. I have never used client side validation, so I don't know the details. This uses Javascript and displays a popup message if a validation rule fails. If you are not using the framework or you have complex validation rules, you could implement the same type of validation using custom Javascript.

- Brent
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic