• Post Reply Bookmark Topic Watch Topic
  • New Topic

retrieve data row from a table  RSS feed

 
Marianne Moreau
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
I'm using Tomcat and JSTL is of version 1.1
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Eliz Linux", please check your private mesages for an important message from me.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!