java servlet doesn’t work with JavaScript properly

    out.println("<script type='text/javascript' src='app.js'>");
    out.println("Calendar.$calendar = document.querySelector('.calendar')");
    out.println("Calendar.$date = document.querySelector('.cur-date')");
    out.println("Calendar.init()");
    out.println("</script>");
    out.println("</body></html>");

I’m trying to make the code for Full year calendar that can add to-do list on any date you choose. but it seems to doesn’t work.

when I run this code. It’s showing me this error.
Uncaught TypeError: Cannot set properties of undefined (setting ‘innerHTML’)

how do I fix this problem?