Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!

Bear Bibeault

Author and ninkuma
+ Follow
since Jan 10, 2002
Bear likes ...
IntelliJ IDE Java jQuery Mac Mac OS X
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 Ranch Hand Scavenger Hunt Green check
expand Greenhorn Scavenger Hunt Green check

Recent posts by Bear Bibeault

The use of scriptlets (the Java code delimited via <% and %>) is obsolete and should not be used.

Welcome to the Ranch.
16 hours ago
As with any modern JSP, you insert dynamic values using the EL (Expression Language) along with the JSTL (JSP Standard Tag Library).

See this article for an explanation of how JSP operates.
16 hours ago
Please read this article to understand how Java Web Apps are structured.
jQuery *is* JavaScript, but regardless...

Set breakpoints where you think the code is going wrong.

You might also want to rethink your naming of variables and parameters. The ones you have seem confusiing.
If you are already using jQuery why would you use document.getElementById rather than jQuery notation?

Paul Clapham wrote:You're kidding! That's pretty close to professional malpractice in my book.

Not to pile on -- but I will -- it's like teaching an electronics course using vacuum tubes.

I know you have no control over the curriculum, but please do be aware that, as Paul said, JSP scriptlets have been obsolete since 2002. When you get a chance (if servlets and JSP will be important to you going forward) study up on the EL (Expression Language) and JSTL (JSP Standard Tag Library) as the modern equivalents.

Good luck with your studies.
1 week ago
OK, first things first. Please tell us how you are running this code. Obviously not in the browser. With NodeJS? Java's JS runtime?

If NodeJS, what version? It may not support all ES6 syntax yet.

You may need to set up a Babel build to convert to ES5 for execution.

Which tutorial is this coming from? You're not giving us much to work with here.

And checking for syntax errors is not considered "debugging". Debugging happens at run time.

Rocky Rocha wrote:My code is fine, I debugged it. Anyone know what's going on?

How can you debug it if it won't run?
The destructuring syntax is new with ES6. Are you sure your interpreter supports it?
Before digging into any depth in your code, using a 2-D matrix to store structured data is a huge anti-pattern. You data should be a single-dimension array of objects, each with object properties to reflect the values of each question: its text, choices, and so on.

Restructure your data, refactor your code to accommodate the change, and then see if any problems still exist.

Think about these conditions. How may times does the loop iterate?
Please research the allowed values for the font-style property. Hint: it's not font names.
When a class is created, only a single instance is created, not both a subclass instance and a superclass instance. So there's only the subclass instance that inherits from the superclass.
2 weeks ago
I get my eyes checked yearly. Here how it goes:

Dr. Weaver: Cover your right eye and read as many lines as you can.
Me: (reads maybe top two lines)
Dr. Weaver: Now cover your left eye and read the chart.
Me: What chart?

My right eye is useless. It's what called a lazy eye. For whatever reason (speculation is that my congenital hemangioma affected the optic nerve during development), my visual cerebral cortex for the right eye never developed.

My left eye is extremely far-sighted. Without my glasses I cannot read anything but the largest of signs.

If the zombie apocalypse comes and I break my glasses, I'm screwed.
2 weeks ago