Sure you can, please if you are using struts2 please read these tutorials Struts2 Tag lesson http://www.tutorialspoint.com/struts_2/ or http://struts.apache.org/docs/tag-reference.html and a bit of JSP EL http://www.tutorialspoint.com/jsp/jsp_expression_language.htm -- Thanks & Regards Sreekanth S Nair Java Developer ------------------------------------------- eGovernments Foundation Ph : 9980078913 ------------------------------------------- ------------------------------------------- On Tue, Dec 30, 2014 at 4:47 AM, Albert Kao wrote: > The following Java scriptlet code in a Struts jsp is working fine. > However, is it possible to change the jsp code so as to remove all > the Java scriptlet codes? > > The .jsp code is like this:<% > HttpSession httpSession = request.getSession(true); > MyClient myClient = > (MyClient)httpSession.getAttribute(MyConst.MY_CLIENT); > %> > property="pOwners" length="<%=MyConst.MY_OWNER_MAX%>" indexId="index"> > <% > pageContext.setAttribute("requiredIndex", > myClient.getRequiredIndex(index), PageContext.PAGE_SCOPE); > %> >

> <%= > myClient.getNumber(index) %> >

> >
> > > > > > > styleId='<%="lastName" + index%>' name="inputForm" > property='<%="myForm.pOwners["+index+"].lastName"%>' size="62" > maxlength="30" /> >
>
> > > The java code is like this:public class Owner implements > java.io.Serializable { > private static final long serialVersionUID = 7920764268572909394L; > private String lastName; > private String ownershipCode; > //... > > public Owner() { > } > > // getter and setters > public String getLastName() { > return lastName; > } > > public void setLastName(String lastName) { > this.lastName = lastName; > } > > //... > public Integer getRequiredIndex(Integer index) { > Integer requiredIndex = index; > if (OWNRSHP_PARTNER.equals(ownershipCode)) { > requiredIndex = requiredIndex - 1; > } > return requiredIndex; > } > > public String getNumber(Integer index) { > String number = Integer.toString(index + 1); > if (OWNRSHP_SOLE.equals(ownershipCode)) { > number = ""; > } > return number; > } > } > >