Bela Takacs

Greenhorn
+ Follow
since Sep 24, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Bela Takacs

Dear Bear and Stefan,

Thank you very much for your help!! Based on your answers, I created a solution. I post it, because someone might be interested. So, the SpecialImage.jsp:



And the OneImage.jsp:



@Bear: Now, I am trying to make this happen without scriptlet code. I am a Greenhorn here, so I ask: if I encounter problems with getting rid of the scriptlet code, should I open a new topic, or should I post my question to this topic?

Best regards
Bela
5 years ago
JSP
Dear Bear,

This is the transition, because SpecialImage.jsp needs an image from OneImage.jsp:


Kind regards,
Bela
5 years ago
JSP
Dear Stephan,

I cannot stick with the request parameter. My OneImage.jsp needs the "theGivenBook" object of SpecialImage.jsp, because the "theGivenBook" object has variables that contain images. The request variable is only a String, so it cannot contain images (as far as I know).

Is there a better way to pass an object between the two JSPs? What is the standard way to pass and receive an object?

Kind regards,
Bela
5 years ago
JSP
Dear Bear,

I don't know exactly what you mean by the word "relationship" between the two JSPs. The SpecialImage.jsp has a forEach iteration. It iterates over a java.util.List of Books. Books are POJO-s, with variables like: title, author, ISBN_number, coverImage, usw. (I select these Books from Hibernate/MySQL.) So, ${allItems} is a List of Books. In the forEach iteration, ${oneItem} represents the Book, that is investigated in the n-th iteration.

In every iteration the SpecialImage.jsp puts the ${oneItem} object into the session (variable "theGivenBook") and then SpecialImage.jsp "calls" OneImage.jsp. Have a look at the code again:



OneImage.jsp tries to get the object that SpecialImage.jsp has put into the session. So, for example, if I have got 20 Books, I mean, ${allItems} has twenty ${oneItem}, then OneImage.jsp will be called twenty times. And, of course, OneImage.jsp will try to get the variable "theGivenBook" from the session 20 times. So the code:


My problem is: the OneImage.jsp always gets the last value of variable "theGivenBook". I mean, when I receive the value of "theGivenBook" in OneImage.jsp, "theGivenBook" always has the very same value (although I set it to a different value in each and every iteration). For example, if I have 20 Books, then in the OneImage.jsp, the variable "theGivenBook" will always contain the very same Book object (regardless of iteration).

Bear, please, tell me, if I am not clear enough.

Kind regards,
Bela
5 years ago
JSP
Dear JSP programmers,

My first JSP: SpecialImage.jsp



My second JSP: OneImage.jsp (Yes, I know, it is a scriptlet, but that is not the point here. At least, not at the moment.)



The results of the System.out.println:
Param ISBN: 1451581718 bi.ISBN: 0132618206
Param ISBN: 1449380344 bi.ISBN: 0132618206
Param ISBN: 0596800959 bi.ISBN: 0132618206
Param ISBN: 0470502266 bi.ISBN: 0132618206
Param ISBN: 0132618206 bi.ISBN: 0132618206

It is strange and bad, that "bi.ISBN" has always the same value (0132618206).
I think, "Param ISBN" and "bi.ISBN" should always have the same value. I mean, if in an iteration the "Param ISBN"=1451581718, then the "bi.ISBN" should also have the value of 1451581718.

Remark:
As the title of my topic suggests, my original problem is, that I need the value of the forEach variable "oneItem" in my second JSP (OneImage.jsp). So, as you see in my first JSP (SpecialImage.jsp) I try to use the core:set tag with scope=session. But I am unsuccessful, because the value of bi.ISBN is always the same (in each iteration). Please, tell me, how could I get the value of the forEach variable "oneItem" in my second JSP.

Kind regards,
Bela

5 years ago
JSP