-2
    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?

Wonjun Jo
  • 5
  • 1
  • Basically this is not a servlet or Java question. The problem is purely in the HTML & Javascript documents. It is not relevant how they are being served to the browser. – Stephen C Mar 12 '23 at 07:31
  • With script tag you can either provide a source file to load the code from or can have the code mentioned within the script tags, cannot mix both. – sanjeev Aug 25 '23 at 18:39

1 Answers1

0

Your script tag has a src attrib and contents. This will cause undesired behaviour. See this question.

The fix is to change this

out.println("<script type='text/javascript' src='app.js'>");

into this:

out.println("<script type='text/javascript' src='app.js'></script>");
out.println("<script type='text/javascript'>");
John Williams
  • 4,252
  • 2
  • 9
  • 18