I may be wrong but the answer to this is seemingly simple, but unknown to me.
My Problem: Let's say I'm trying to set myself up for a mock OCP test and I'd like to keep count.
My Approach :
Step 1: Create a form (form 1) that accepts the total number of questions (say 70) and the duration of the exam in minutes (150); pass these request parameters to another form (form 2)
Step 2: In form 2, set up a table with 70 rows (total number of questions), with column 1 numbered 1 through 70, and column 2 containing 1 text field per row, with my guess/answer (A/B/C/D etc.).
I'm able to access Form1's request parameters in Form2 using a JSP expression; my need though for Form 2, is a table-like display with blank text fields per question, so a forEach is the key.
My attempts to access the request parameters within the forEach tag have failed so far.
By the way you generally can't just put Java code into JSTL and hope it will work. JSTL is a language of its own, and it should have most features which you need to produce HTML. If not, then you can write your own tag libraries (in Java).
Maybe I am seeing different behaviour than you because of the difference in JSTL libraries.
I tested using Tomcat 220.127.116.11, which it looks like is using this implementation:
posted 1 week ago
Thanks Ron! The good news - I've got what I wanted; the not so good news - I'm not sure how.
The problem turned out more annoying...somehow, the sessionScope and param references weren't being read, despite me having added what I thought were the correct libraries.
I had previously accessed requestScope, so this was a bit bothersome. Just when I was about to give up, I did a few things that ended up working for me.
Here's a summary involving A) the deployment descriptor and B) , the POM. Could you help me disambiguate ?
A) I initially used a maven-archetype-webapp archetype to create this project. I added the following dependencies initially:
The archetype choice created a Deployment Descriptor file with the following content, as it would
….I changed this explicitly to the following, based on an internet source that I don't recall now...
B) I also added the jstl-api library along with the previously added dependencies, so that my POM dependencies looked as follows:
Now, I'm not sure if the last dependency did the trick, or if it was the DD change; it initially didn't work, but then somehow, after a quick, unrelated edit to the JSP (printing the requestScope and sessionScope side by side), it started working.
I'm able to access sessionScope and param variables now.
Here's an excerpt from the JSP, that falls in line with my original requirement.
Could you throw some perspective into this if possible ? Is JSP engine unpredictable in that way ? Did adding the additional library do the trick, or was it the DD ?
I apologize for the open ended question; I don't like the fact that I don't know what worked.