This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
How could one keep track of the row (or a field in that row specifically) in the database in jstl 'forEach' iteration over the rows of database when a user licks on the image button on each row? Just to be clear, the 'index' property of 'varStatus' just keeps track of the row in the iterated collection, not in the database. For some reason, the editor did not let me post the codes here. Many thanks.
My guess would be you are presenting an "index" of thumbnail images, and then you want the user to click on one, and see it in full detail?
Easiest way is to put a url on each image, with the id of the image in question as a parameter. Something like this (using JSP2.0)
Joined: Jun 20, 2003
Bear, you were correct in your guess. Sorry that I wasn't clear enough. Yes, clicking on the image link(button) directs the user to another jsp page.
Greg, it was hot here so I was thinking for a full min but still didn't get your joke
Steffan, yes I followed a similar approach by using 'value' property instead of 'id' property.
I got things worked out by saving the value of 'varStatus' within the collection then pass the whole collection to the second jsp page in session scope. One thing I noticed though, is that if a field is CLOB or BLOB, its contents won't be retrievable at all from session variable. The error message complained of a failed database connection. It seems as though jstl <c:set .... scope="session"> only passes the references to the CLOB/BLOB objects, not the actually objects. For example, in a scriptlet in the forwarded jsp, I was able to print out the Clob object (after retrieve it from session variable and typecasting it to Clob- (something like oracle.sql.CLOB@7634gadfa6) but if I tried to print out object.length(), I got that error message. I now have to resort to open another database connection in a scriptlet (instead from jstl <sql:setDatasource ...> tag), then use the getClob(). Any other alternative? Thank you all for the help. [ August 29, 2006: Message edited by: thomas silver ]
Database access and binary file manipulation from a JSP is never a good idea. The accepted 'best practice' these days is to write Java objects that deal with the database and return the results as arrays or collection objects. Call these objects from servlets and then pass the results to a JSP for formatting.
Even the JSTL spec states that the JSTL/SQL tags were not meant for anything other than prototyping or trivial apps. In my opinion, they never should have been written.