Re: replace Java scriptlets in JSP page

2014-12-30 Thread Christoph Nenning
> 
> 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


Re: replace Java scriptlets in JSP page

2014-12-30 Thread Albert Kao
I am using struts 1 because of company policy.
 

 On Monday, December 29, 2014 11:20 PM, Sreekanth S. Nair 
 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 
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;
>    }
> }
>
>


   

Re: replace Java scriptlets in JSP page

2014-12-29 Thread Sreekanth S. Nair
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;
> }
> }
>
>


replace Java scriptlets in JSP page

2014-12-29 Thread Albert Kao
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);
%>

  <%
    pageContext.setAttribute("requiredIndex", myClient.getRequiredIndex(index), 
PageContext.PAGE_SCOPE);
  %>
  
     <%= myClient.getNumber(index) %>
  

  
    
  
    
    
  
    
    
  ">
    
  
    
    
  



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;    
    }
}