raghujosh 0 Junior Poster

How can I pass multiple values from a JSP to a servlet using an hyperlink. Following is my code

<div style="width:500px;height:20px;border:2px solid blue; padding-top:25px; padding-left:40px; padding-right:20px; padding-bottom:10px;">
<jsp:include page = "/Alphabet.jsp"/>
</div>
<a href = "cart.jsp"><img src="shopping_cart.jpeg" width=50 Height=75 alt="Shopping Cart" border="0" style="float:right;"></a>



<%@ page import="com.classes.chemical.*, java.util.ArrayList" %>
<td width = "500" valign = "center" colspan = "3">
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>


<h1> Here is the chemical list as per your category selection</h1>

<table cellpadding = "10" border = "1">
<tr valign = "bottom">
<th align = "left" > Catalog No </th>
<th align = "left" > Chemical Name </th>
<th align = "left" > Unit </th>
<th align = "left" > Price </th>
<th align = "left" > Vendor </th>
<th align = "left" > Category </th>
<th align = "left" > Account No</th>
</tr>



<%

try
{
	ArrayList<CartProduct> cp3 = (ArrayList<CartProduct>) session.getAttribute("cp");
for(CartProduct pp: cp3)
{
%>
	<tr>
	<td><input type = "hidden" name = "catNo" value="<%=pp.getCatNo()%>"><%=pp.getCatNo()%></td>
	<td><%=pp.getChemName()%></td>
	<td><%=pp.getChemUnit()%></td>
	<td><%=pp.getPrice()%></td>
	<td><%=pp.getVendor()%></td>
	<td><%=pp.getCategory()%></td>
	
	<td><select name = "accno"><option value="--Select--">--Select--</option>
<%ArrayList<String> str=pp.getAccList();
for(String s:str)
{
%> <option value="<%=s%>"><%=s%></option>
  <%  
}
%>
</select></td><td><a href="DisplayCartServlet?catNo=<%=pp.getCatNo()%>&accountno=accno">Add To Cart
    </a></td>
	</tr>
<%
}
}
finally{


}
%>

I want to pass catNo and accountno. But only catNo is valid at this time. accountno is null at the servlet. Accno is the selection from the listbox.

</table>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.