Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing variable in anchor tag

 
nishi kishore
Ranch Hand
Posts: 32
Chrome Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
my problem is as follows :

i am retrieving the data from the table product in database attadb.
the column names in this table are as follows : product_id,product_name,product_brand,product_price,product_discount,product_seller_name,product_image
the columns which i am retrieving from this table are : product_name,product_brand,product_price,product_discount only
the code is as follows :



rsPagination is the RESULTSET.
in this code, i am using a hyperlink on product_name column. when this code executed, it will retrieve the values of specified columns under the labels :
PRODUCT NAME PRODUCT BRAND PRODUCT PRICE PRODUCT DISCOUNT
now, when the user clicks on the particular PRODUCT NAME value, it will be redirected to the showproduct.jsp page.but i want to show the details of only that product in the showproduct.jsp page.
if the user clicks on product name microwave, it will show the data for microwave in the showproduct.jsp, if the user clicks on airconditioner, it will show the data for airconditioner in the showproduct.jsp.

please help me to sort out this problem.

thanks and regards
nishi kishore
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do products have an ID? Use that as a parameter to your showProduct.jsp.

You're using a couple of bad practices here though. First, scriptlets have been deprecated for ten years. JSTL is much easier to read and maintain. Second, don't work with DB objects in your JSP. Retrieve your data and store it a collection somewhere, probably a request attribute, and forward to the JSP for presentation.
 
nishi kishore
Ranch Hand
Posts: 32
Chrome Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have already metioned in this post. product table has also a column product_id.
but i have more than 2 product_name with the same name.
like i have airconditioner with 4% discount, again a airconditioner with 5% discount etc.

same is the case for other products.

i havent any idea about JSTL. i never learnt about the JSTL
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64830
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now is the time to learn.
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You said there's a product ID in your database table, but you're not retrieving it. Retrieve it, and use it in the anchor tag.

Learning JSTL is not a big time commitment. Try it out and in a week, you'll be wondering why you ever used scriptlets.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic