wood burning stoves*
The moose likes JSP and the fly likes passing variable in anchor tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "passing variable in anchor tag" Watch "passing variable in anchor tag" New topic
Author

passing variable in anchor tag

nishi kishore
Greenhorn

Joined: Jun 21, 2012
Posts: 28

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

Joined: Oct 01, 2001
Posts: 2840
    
  11

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
Greenhorn

Joined: Jun 21, 2012
Posts: 28

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

Joined: Jan 10, 2002
Posts: 60800
    
  65

Now is the time to learn.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2840
    
  11

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: passing variable in anchor tag
 
Similar Threads
Unable to fetch data on a specific JSP....getting error "HTTP Status 404 - /getData.do"... help.
How to loop through data on a jsp form?
Processing checkboxes data.
Problem while creating Struts application
calculation on data retrieved from database