Win a copy of OCP Oracle Certified Professional Java SE 11 Developer Practice Tests this week in the OCP forum!

Bear Bibeault

+ Follow
since Jan 10, 2002
Bear likes ...
Mac Mac OS X IntelliJ IDE jQuery Java
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

Welcome to the Ranch.

Firstly, you should not be putting Java code in a JSP. That is a practice that has been obsolete for almost 20 years. 20 years!

The error message is pretty clear, UserDao has not been imported. But really, no Java code in a JSP.
1 month ago
Only top-level vars become properties of the window object, not block-level vars, and that is an implementation detail of the browser. There is no window object in other JavaScript environments. So don't think of vars as properties of some global object in general.

P.S. In modern JavaScript (not "java script") var should not be used; use let and const which have clearer semantics. And, write modular code, avoiding global-level declarations.
It wouldn't be much of a security measure if it could be easily bypassed.

Spring Boot and other Java apps run on the server and have no access to the client machine.

What is it that you are specifically trying to accomplish? You may need to run an agent on the client (which of course requires the permission of, and actions by, the user).
No. Security concerns prevent the browser from having such access to the file system.

Steve Dyke wrote:
I just want to be clear. If I use static methods will they be bound to the session?

No. They will not be bound to any servlets scope. Just import the class containing the static methods and call them. They are just available in the classpath like any other Java program. No scopes needed.

So if I call the static method with parameters and the properties of the class are based on a function using the parameters the properties will hold their value until I call the method with a different set of parameters?

No. Parameters only "exist" while the function that they are passed to is executing. Just like any other Java program.

And again all this will be at the session level?

Again, no scopes.

You shouldn't have to do the conditional.

P.S. Why bother with IE? Even MS doesn't support it.
So what you are saying is that the event handler is invoked only on IE and no other browser, correct?

That would be weird as it is supported on all browsers.

If so, then perhaps something at a higher level is at play. Is this code at the top-level, or within other code or handlers?
Did you set a breakpoint?

Do the dev tools shows that the request was triggered? Did it succeed?

Pout a try/catch around the post to handle errors. Also you can add a done callback for the promise just to check if it is being called.
That last makes no sense: if the handler isn't being called, how would the preventDefault be executed?

What makes you think that the post isn't firing? Have you set a breakpoint to make sure the code is being executed? What sort of error handling do you have in case the post fails?
Is the handler code executing? What *is* happening?
Try returning false to stop the event. If that doesn't work, call preventDefault on the event object (passed to the hander, see docs).
According to MDN, this event is supported by Edge. Does it work in other browsers?

Question: you are clearly using jQuery, why are you not using jQuery event handling?