• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

keep track of database row in jstl 'forEach' iteration

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure what you mean. By the time users are presented with an opportunity to click anything, the JSP has long seen finished executing.

Are you talking about how to identify which row's data the user clicks on after the JSP has been delivered and a subsequent submit is performed?
[ August 28, 2006: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by thomas silver:
...when a user licks on the image button on each row?



I'd hate to get that user's hand me down monitor. Ewe!
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)

 
thomas silver
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic