Re: replace Java scriptlets in JSP page
I am using struts 1 because of company policy. On Monday, December 29, 2014 11:20 PM, Sreekanth S. Nair sreekanth.n...@egovernments.org wrote: 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 http://www.egovernments.org Ph : 9980078913 --- http://in.linkedin.com/pub/sreekanth-s-nair/b/946/5a0/ https://github.com/sreekanthsnair sreekanthsn...@hotmail.co.uk sreekanths...@gmail.com --- On Tue, Dec 30, 2014 at 4:47 AM, Albert Kao albertk...@yahoo.ca 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); % logic:iterate id=pOwnersID name=%=MyConst.MY_CLIENT% property=pOwners length=%=MyConst.MY_OWNER_MAX% indexId=index % pageContext.setAttribute(requiredIndex, myClient.getRequiredIndex(index), PageContext.PAGE_SCOPE); % h2 bean:message key=common.owner.label / %= myClient.getNumber(index) % /h2 div logic:lessThan name=requiredIndex value=1 label for='%=lastName + index%' class=required bean:message key=common.lastName.label / jsp:include page=/pages/common/required.jsp flush=true / /label /logic:lessThan logic:greaterEqual name=requiredIndex value=1 label for=%=lastName + index% bean:message key=common.lastName.label / /label /logic:greaterEqual html:text styleClass=form-control styleId='%=lastName + index%' name=inputForm property='%=myForm.pOwners[+index+].lastName%' size=62 maxlength=30 / /div /logic:iterate 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; } }
Re: replace Java scriptlets in JSP page
I am using struts 1 because of company policy. With struts1 you can use JSTL EL, too. The form bean names are available in EL. And struts1 has it's own tag lib. regards, Christoph This Email was scanned by Sophos Anti Virus
replace Java scriptlets in JSP page
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); % logic:iterate id=pOwnersID name=%=MyConst.MY_CLIENT% property=pOwners length=%=MyConst.MY_OWNER_MAX% indexId=index % pageContext.setAttribute(requiredIndex, myClient.getRequiredIndex(index), PageContext.PAGE_SCOPE); % h2 bean:message key=common.owner.label / %= myClient.getNumber(index) % /h2 div logic:lessThan name=requiredIndex value=1 label for='%=lastName + index%' class=required bean:message key=common.lastName.label / jsp:include page=/pages/common/required.jsp flush=true / /label /logic:lessThan logic:greaterEqual name=requiredIndex value=1 label for=%=lastName + index% bean:message key=common.lastName.label / /label /logic:greaterEqual html:text styleClass=form-control styleId='%=lastName + index%' name=inputForm property='%=myForm.pOwners[+index+].lastName%' size=62 maxlength=30 / /div /logic:iterate 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; } }
Re: replace Java scriptlets in JSP page
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 http://www.egovernments.org Ph : 9980078913 --- http://in.linkedin.com/pub/sreekanth-s-nair/b/946/5a0/ https://github.com/sreekanthsnair sreekanthsn...@hotmail.co.uk sreekanths...@gmail.com --- On Tue, Dec 30, 2014 at 4:47 AM, Albert Kao albertk...@yahoo.ca 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); % logic:iterate id=pOwnersID name=%=MyConst.MY_CLIENT% property=pOwners length=%=MyConst.MY_OWNER_MAX% indexId=index % pageContext.setAttribute(requiredIndex, myClient.getRequiredIndex(index), PageContext.PAGE_SCOPE); % h2 bean:message key=common.owner.label / %= myClient.getNumber(index) % /h2 div logic:lessThan name=requiredIndex value=1 label for='%=lastName + index%' class=required bean:message key=common.lastName.label / jsp:include page=/pages/common/required.jsp flush=true / /label /logic:lessThan logic:greaterEqual name=requiredIndex value=1 label for=%=lastName + index% bean:message key=common.lastName.label / /label /logic:greaterEqual html:text styleClass=form-control styleId='%=lastName + index%' name=inputForm property='%=myForm.pOwners[+index+].lastName%' size=62 maxlength=30 / /div /logic:iterate 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; } }