i will be having three fields- from data, to date, no. of days in my User interface developed using htm5l-css3-javascript also there will be database with java as backend code.

when the user selects the "from" and "to date" i want the no. of days to be calculated automatically. also it should exclude saturday and sunday plus public holidays.

how do i do it. using javascript, or using java code? or is there a better way.