• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Value not pass correctly

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I need a help on JSP code which was done 5 years back. I'm new to the JSP and below is the code. Problem is "ckdconfirm" when submit this value reflect as NULL and variables in here "document.location="trandtl.jsp?oZone="+yy+"&tableCode="+zz+"&huser="+xx+"&cAteCode="+cc ;" gets NULL. How can i solve this issue. I attached the page.

out.println("<table width='100%' align='left' border=1 border color='black' cellpadding='2' cellspacing='0'>");
out.println("<tr class='cTitlek'><td style='width: 90px' >ชื่อสินค้า</td><td><input type='submit' name='ckdconfirm' id='ckdconfirm' value='ตกลง' style='width: 90px;font-size:20pt;' /></td></tr>");


sqlc = "SELECT * FROM PDA_SO_ITEMS_CKD WHERE TABLE_CODE='"+c+"' AND REF_SEQ='"+no+"' ";
rsc = stmt5.executeQuery(sqlc);


while(rsc.next()){

%>

<input type="hidden" name="kitem" id="kitem" value="<%=rsc.getString("ITEM_CODE")%>" />
<input type="hidden" name="kseq" id="kseq" value="<%=rsc.getString("SEQ_NO")%>" />
<input type="hidden" name="krefseq" id="krefseq" value="<%=rsc.getString("REF_SEQ")%>" />
<input type="hidden" name="kkuser" id="kkuser" value="<%=tuser%>" />
<input type="hidden" name="kktab" id="kktab" value="<%=otableCode%>" />
<input type="hidden" name="kkzone" id="kkzone" value="<%=dZone%>" />
<input type="hidden" name="kkcat" id="kkcat" value="<%=oCateode%>" />

<tr class="cTitlek">
<td width="20"><select name="kproduct" id="kproduct" style="width: 250px; background-color:white; font-size:20pt; color:black; font-family:Tahoma;">
<option value="<%=rsc.getString("ITEM_CODE")%>" ><%=rsc.getString("ITEM_NAME")%></option>

<%
String pproduct =rsc.getString("PRODUCT_CODE");
String ppseq =rsc.getString("SEQ_NO");
String ppitem =rsc.getString("ITEM_CODE");

ResultSet r5=stmt2.executeQuery("SELECT ITEM_CODE,ITEM_NAME ,3 FROM CKD_ITEM_DTL_CHOICE WHERE PRODUCT_CODE='"+pproduct+"' AND PRODUCT_STOCK_TYPE='1' AND REF_SEQ= '"+ppseq+"' AND ITEM_CODE!= '"+ppitem+"' UNION ALL SELECT ITEM_CODE,ITEM_NAME ,3 FROM CKD_ITEM_DTL WHERE PRODUCT_CODE='"+pproduct+"' AND PRODUCT_STOCK_TYPE='1' AND SEQ_NO= '"+ppseq+"' AND ITEM_CODE!= '"+ppitem+"' UNION ALL SELECT ITEM_CODE,ITEM_NAME,1 FROM PDA_SO_ITEMS_CKD WHERE TABLE_CODE = '"+a+"' AND REF_SEQ = '"+no+"' AND SEQ_NO = '"+ppseq+"' AND ITEM_CODE!= '"+ppitem+"' ORDER BY 3 " );
while(r5.next())
out.print("<option value="+r5.getString(1)+">"+r5.getString(2)+"</option>");
%>

</select>
</td>
<tr>

<%

}

}
}
}
%>
<%
String submitchk = request.getParameter("ckdconfirm");
if(submitchk != null){
String upduser=request.getParameter("kkuser");
String ktab = request.getParameter("kktab");
String kseq[] = request.getParameterValues("kseq");
String krefseq = request.getParameter("krefseq");
String kitem[] = request.getParameterValues("kitem");
String kproduct[] = request.getParameterValues("kproduct");

if (kitem!= null)
{
for (int i = 0; i < kitem.length; i++)
{
PreparedStatement pstmt = con.prepareStatement("UPDATE PDA_SO_ITEMS_CKD SET ITEM_CODE = ? WHERE SEQ_NO = ? AND REF_SEQ=? AND TABLE_CODE = ?");
pstmt.setString(1, kproduct[i]);
pstmt.setString(2, kseq[i]);
pstmt.setString(3, krefseq);
pstmt.setString(4, ktab);
pstmt.execute();
}
}

%>

<%
sqlc ="SELECT MIN(CAT_CODE) CAT_CODE FROM FOOD_CAT F WHERE F.STATUS='A' AND EXISTS (SELECT 1 FROM STOCK_POS S ,STORE_COST_CENTER SC WHERE S.COMPANY_CODE=SC.COMPANY_CODE AND S.COST_CENTER_CODE=SC.COST_CENTER_CODE AND S.STOCK_POS_CODE=SC.STOCK_POS_CODE AND F.COMPANY_CODE=S.COMPANY_CODE AND F.STOCK_POS_CODE=S.STOCK_POS_CODE AND EXISTS (SELECT 1 FROM EMP_WORK_TIME_DETAIL E WHERE E.COMPANY_CODE=S.COMPANY_CODE AND E.COST_CENTER_CODE=S.COST_CENTER_CODE AND E.WORK_DATE=TRUNC(SYSDATE) AND E.SALESMAN_CODE='"+tuser+"')) ORDER BY 1";
rsc=stmt.executeQuery(sqlc);
while(rsc.next()){
%>
<input type="hidden" name="ordermincat" id="ordermincat" value="<%=rsc.getString("CAT_CODE")%>" />
<%
}
rsc.close();
stmt.close();
stmt2.close();
stmt3.close();
stmt4.close();
con.close();
%>


<script language="javascript">

var cc ="<%=request.getParameter("ordermincat")%>";
var xx ="<%=request.getParameter("duserid")%>";
var yy ="<%=request.getParameter("zzone")%>";
var zz ="<%=request.getParameter("tableCode")%>";

document.location="trandtl.jsp?oZone="+yy+"&tableCode="+zz+"&huser="+xx+"&cAteCode="+cc ;
</script>

<%
}
%>
 
Marshal
Posts: 7402
1423
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to Javaranch!

If xx, yy, zz, and cc gets null, it must be because you have not passed the parameters of duserid, zzone, etc...

Thameera Nawaratna wrote:I need a help on JSP code which was done 5 years back


Scriptlets in JSPs is an anti-pattern that has been obsolete for over 15 years. You should never use scriptlets in your JSPs in these days. If you want to tweak this code, I'd suggest start it by refactoring it to use a proper MVC approach, where you use a servlet to control requests, and JSPs only for viewing purpose.

 
Thameera Nawaratna
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Agreed Devaka. I have suggested the same. But company need to fix this code as it is. Thanks Found the issue. Issue was "request.getParameter". I used document.getElementById and the issue resolved.

 
reply
    Bookmark Topic Watch Topic
  • New Topic