Form Validation using JSP/Javascript

Hi,

I am developing a web application using JSP/Servlet. I have a form in .jsp where user uploads excel file which is then processed and an excel output is generated. I need to validate input file to see if a certain cell in the workbook has some value as soon as the user selects input (before hitting Submit). Right now, I am just calling a javascript function on the onChange() method of HTML file input control. Can I call a jsp function within javascript to read excel file data? Please suggest what is the best approach?

Thanks.

Validation with JSP is possible only after you upload that document. For this you will need to open that file and to check specific field… (there are several libraries like http://jexcelapi.sourceforge.net/ or this one http://poi.apache.org/ which you can use for this purpose)

Javascript can be used only to check are all fields on your form filled correctly or is selected file extension the right one.

I’m using Javascript validation but I don’t trust it to much. Implementing a server side validation is a MUST…

Hi,

Thanks for your reply. Is there any other method of validating the input file before submitting the form? Can AJAX be used for this purpose?

Thanks.

Any validation done with Javascript (including AJAX) can be easily circumvented by a user simply by switching off javascript within their browser.

The only way to be sure validation gets done is to do it server-side.

That said, it can be done via JSP, as JSP is server-side, but using a servlet is much preferred.

Why not use MVC framework which already includes validation feature?