views:

663

answers:

1

code is below:

<select name="merTransactionTypeId" class="cbox"  multiple>
  <!--
  <option value="0" <%=request.getParameter("merTransactionTypeId")!=null?"0".equalsIgnoreCase(request.getParameter("merTransactionTypeId"))?"selected":"":""%>>All</option>
  --> 
  <option value="2" <%=request.getParameter("merTransactionTypeId")!=null?"2".equalsIgnoreCase(request.getParameter("merTransactionTypeId"))?"selected":"":""%>>Reload</option>
  <option value="1" <%=request.getParameter("merTransactionTypeId")!=null?"1".equalsIgnoreCase(request.getParameter("merTransactionTypeId"))?"selected":"":""%>>Sale</option>
  <option value="5" <%=request.getParameter("merTransactionTypeId")!=null?"5".equalsIgnoreCase(request.getParameter("merTransactionTypeId"))?"selected":"":""%>>CCMS_Recharge</option>             
  <option value="6" <%=request.getParameter("merTransactionTypeId")!=null?"6".equalsIgnoreCase(request.getParameter("merTransactionTypeId"))?"selected":"":""%>>Loyalty_Award</option>      
  <option value="7" <%=request.getParameter("merTransactionTypeId")!=null?"7".equalsIgnoreCase(request.getParameter("merTransactionTypeId"))?"selected":"":""%>>Loyalty_Redeem</option>     
  <option value="16" <%=request.getParameter("merTransactionTypeId")!=null?"16".equalsIgnoreCase(request.getParameter("merTransactionTypeId"))?"selected":"":""%>>FCC_Reload</option>
  <option value="11" <%=request.getParameter("merTransactionTypeId")!=null?"11".equalsIgnoreCase(request.getParameter("merTransactionTypeId"))?"selected":"":""%>>Tracking</option>
  <option value="12" <%=request.getParameter("merTransactionTypeId")!=null?"12".equalsIgnoreCase(request.getParameter("merTransactionTypeId"))?"selected":"":""%>>Fund_Transfer_From_Card</option>                  
</select>

i am trying to retrieve values from dropdown with code in scriplet as

<% String[] selectedTransactionTypes = request.getParameterValues("merTransactionTypeId"); %>

...but it's returning null. Please help me out.

+1  A: 

Apparently the listbox isn't enclosed in the same <form>, or there's even no means of a <form>, or maybe you tried to access it at the wrong moment (e.g. before form submit), or maybe there's a typo in the parameter name (use getParameterNames() to view them all).

That said, I strongly recommend you to leave the old fashioned scriptlets aside and go ahead with a servlet class to preprocess and postprocess the request and taglibs/EL to control the flow and access data in JSP. It will make your code much cleaner.

BalusC