jsp - How to print cn.replace("cn=", "") as <input value> using EL -


i turnig jsp code:

<%      (int = 0; < list.size(); i++) {         entry var = (entry) list.get(i);         out.println(var.getcn().replace("cn=", ""));         string cn = var.getcn();         out.println("<form method=\"get\" action=\"controller\">"                 + "<input type =\"hidden\" name=\"act1\" value = \"" + cn.replace("cn=", "") + "\">"                 + "<button type=\"submit\" name=\"act\"  value=\"show\" id=\"act\" >show</button>"     } 

into jstl:

  <c:foreach var="item" items="${list}">     <p>         <c:out value="${item.getcn()} "></c:out>         <p>         <c:set var="item" value="${item.getcn()}"></c:set>           <input type ="hidden" name="act1" value ="??????????????">         <button type="submit" name="act"  value="show" id="act">show</button> </c:foreach> 

i don't know how pass parameter "value", uploadable through cn.replace("cn=", "") jsp, servlet.

first remove below line:

<c:set var="item" value="${item.getcn()}"></c:set> 

it's overriding <c:foreach var="item">.

as concrete question, can use singlequotes represent string in el.

<input ... value="${item.cn.replace('cn=', '')}"> 

do note on javabean properties don't need specify whole method name in ${item.getcn()}. can use ${item.cn}.

see also:


unrelated concrete problem, note still prone xss attack hole if concerns user-controlled input, original scriptlet approach too.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -