• 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

retrieve data row from a table

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm new to JSP and I'm doing a project on it.
I am trying to adapt the MVC model as much as possible.
So, my Controller talks to the Model which accesses a SQL database to retrieve the required information.Then the Controller dispatches data to the View (the JSP page). I could do these steps successfully (I'm just trying to explaining clearly what I've done so that it would be easier for you to help me).

The retrieved data from the database displayed in the JSP page in rows in a table.
BookTitle Price AddToCart

This result is achieved by:
<c:forEach var="books" items="${listBooks}" varStatus="status">
<tr bgcolor="${status.index % 2 eq 0 ? 'color1':'color2'}">
<td>${fn:escapeXml(books.bookTitle)}</td>
<td>${fn:escapeXml(books.bookPrice)}</td>
</c:forEach>

What I want is that when I click on the HYPERLINK "AddToCart" the corresponding data row (i.e including BookTitle, Price) has be to displayed in a new page with the following format:

Book title: Name of the book
Price: Price of the book

with exactly the same characteristic as in the complete table. That is if the complete table result has alternate colors on rows, the extracted table (
Book title: Name of the book
Price: Price of the book)
must have the same characteristic.

Would you please help me to solve this problem?

Thanks a lot,
Eliz
 
Marianne Moreau
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using Tomcat and JSTL is of version 1.1
 
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
"Eliz Linux", please check your private mesages for an important message from me.
 
Bear Bibeault
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
It sounds as if, when you are clicking on the link, that you want to extract data from the table to send to the new page. This is not a good idea. Firstly, it's just messy -- HTML is a display format, not a data storage format. Secondly, if you are serious about MVC, this would be a rather egregious violation as you are now storing part of your model on the client.

Rather, you should submit back to the server with an identifier (preferably encrypted) for the data you want to display and retrieve it from the model. With regards to view characteristics such as the color, you can carry that along in a request parameter, or temporarily store it in the session (I'd presonally opt for the former).
 
Marianne Moreau
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for your answer.

Could you please be a bit more specific in explaining what should be done? Because I'm a real beginner in JSP, I can hardly understand what you suggested.

Greetings
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic