Bear Bibeault

+ Follow
since Jan 10, 2002
Bear likes ...
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
Forum Moderator
Bear Bibeault currently moderates these forums:
Author of:
Secrets of the JavaScript Ninja, 1st and 2nd editions,
jQuery in Action, 1st, 2nd and 3rd editions,
Ajax in Practice, and
Prototype and Scriptaculous in Action
Austin, TX
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt Green check
expand Greenhorn Scavenger Hunt Green check

Recent posts by Bear Bibeault

The really weird thing about this in JavaScript, is that its value depends not on how the function is declared, but on how it is called.

This makes it unreliable in general functions because you can’t be sure exactly what it’s going to refer to. This is the principal reason that it is now gone from arrow functions.

For event handlers it is much better to rely upon the passsd event than the value of this, which won’t even exist if the handler is declared as an arrow function.

Piet Souris wrote:and then myFunction is a function without any parameter

Nope. All that's happening here is that a reference to the function is being passed. When the function is called, it will get passed the event argument as expected.
And, in the spirit of functional programming, arrow functions should be preferred over named functions, and then the wierdnesses around “this” go away.
See this article regarding proper structure of a Java web application.
4 weeks ago
I use VS Code for frontend development, and IntelliJ for backend.
That's not what a regular expression is intended for. What's wrong with good old comparisons?
For problems like this, and a score of other reasons, Java code in a JSP has been obsolete for over 20 years. 20 years. 2 decades.

Pleaser see this article for a description of how Java web applications should be structured.

2 months ago
Sounds like the most likely cause is that the script is executing before the DOM element identified by 'piechart_3d' exists.

Easiest fix would be to move the script to a script block that is placed after the DOM element.

Most correct fix would be to execute the code in an event handler that executes after the DOM is completely loaded.
Have you followed the instructions in the JSP FAQ for creating server-relative URLs that start with the context path?

If so, you'll need to show your work so we're not just guessing.
2 months ago
For the purposes of local storage there is no distinction; local storages persists across sessions/instances.
local storage survives browser session. session storage is per browser session.
My understanding is that OP is using local storage, not the local file system. But it's still not clear to me exactly what they're trying to accomplish or what the actual issue is...
If you need to save a formatted report, it's customary to have a backend process take the data and either generate a PDF-formatted report, a CSV-formatted report, or an HTML-formatted report (or options for any of the above). Setting the response headers properly makes the response a "download", which the users can then save wherever they please on their file systrm.