You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by anjibman <an...@hotmail.com> on 2010/09/09 16:17:52 UTC

Managing code between Action Class and JSP.

I need the guideline on how to manage data transfer between JSP and action
class. I am using delegate in Action class to get an list of object from the
server and I have to process then display that list in JSP. 

Right now I am getting that list as object from server in action class, put
it in request object and write scripplets in JSP to process the list in the
request object then display it. 

I don't think it is good practice to put scripplets in JSP. I am not sure
where to put those processing part in different class or in Action class
itself or its ok in JSP itself. 

It will be great if anyone can show me with an example to write the code in
manageable way. 

General implementation what I have right now is: 

Action class 
Delegate delegateObject;
resultList = delegateObject.getResult();
request.setAttribute("result",resultList);

JSP
<%
   result = request.getAttribute("result");
   for(loop){
     //Loop to result and display using html tags.
     //e.g. <TD><%= someField %> </TD>
   }
%>

Thanks in advance
-- 
View this message in context: http://old.nabble.com/Managing-code-between-Action-Class-and-JSP.-tp29648167p29648167.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Managing code between Action Class and JSP.

Posted by Chris Mawata <ch...@mathcove.net>.
  On 9/10/2010 11:12 AM, Anjib Mulepati wrote:
> What about doing AJAX call and get result in progression? Isn't this 
> will be efficient way?
>
> Having said that I am trying to find the way to work AJAX with Struts1 
> there is no clear way to do that even though AJAX is just a technology.
>
> Do anyone have any resource in this regards?
>
> Thanks
>
> On 9/10/2010 10:11 AM, Paweł Wielgus wrote:
>> Hi all,
>> the question is if You want to show thousands of records on one page
>> to the user,
>> if yes, thent You need to put them into request or into form,
>> if no then in action put as much as You need into request or form.
>>
>> Best greetings,
>> Paweł Wielgus.
>>
>>
>>
>>
>> 2010/9/10 Anjib Mulepati<an...@hotmail.com>:
>>> One more query suppose "resultList" have thousands of records still 
>>> is it
>>> (using request object and putting all result in it) as
>>>
>>> request.setAttribute("resultObjects", resultList);
>>>
>>>   the efficeint way to send result to view?
>>>
>>> Any alternative to this?
>>>
>>> Thanks
>>> Anjib
>>>
>>>
>>> On 9/10/2010 9:27 AM, CRANFORD, CHRIS wrote:
>>>> As others indicated, it's a matter of using the Struts/JSTL tags.
>>>>
>>>> <ul>
>>>> <logic:iterate id="aFoo" name="resultObjects">
>>>> <li><bean:write name="aFoo" property="propertyName"/></li>
>>>> </logic:iterate>
>>>> </ul>
>>>>
>>>> The biggest difference between Struts1 and what what is posted
>>>> below for Struts2 is how you pass the data to the JSP in my
>>>> opinion.
>>>>
>>>> In Struts1, you would still do as you had in your original
>>>> post:
>>>>
>>>>    request.setAttribute("resultObjects", resultList);
>>>>
>>>> But instead of using the<% ... %>    JSP tags, you would much rather
>>>> using the JSTL, Bean, Logic, Html tag libraries accordingly.  They
>>>> will keep your JSP pages clean and much easier to read.
>>>>
>>>> HTH,
>>>> Chris
>>>>
>>>>
>>>>> -----Original Message-----
>>>>> From: Anjib [mailto:anjibcs@hotmail.com]
>>>>> Sent: Thursday, September 09, 2010 6:27 PM
>>>>> To: Struts Users Mailing List
>>>>> Subject: Managing code between Action Class and JSP.
>>>>>
>>>>>
>>>>>    Yes I am using Struts1.
>>>>>
>>>>> On 9/9/2010 5:10 PM, Greg Lindholm wrote:
>>>>>
>>>>>>> <ul>
>>>>>>> <s:iterator value="%{resultObjects}" var="aFoo">
>>>>>>> <li><s:property value="%{#aFoo.propertyName}" /></li>
>>>>>>> </s:iterator>
>>>>>>> </ul>
>>>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>>
>>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
>
As long as you hold on to the resultList you are holding onto resources. 
Putting it in the request only creates a reference which is only a few 
bytes. The critical question is how long you keep that resultList as 
opposed to how you expose it to the JSP.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Managing code between Action Class and JSP.

Posted by Dave Newton <da...@gmail.com>.
Using Ajax with struts 1 is no different than with anything else.

Dave

On Sep 10, 2010 11:13 AM, "Anjib Mulepati" <an...@hotmail.com> wrote:
> What about doing AJAX call and get result in progression? Isn't this
> will be efficient way?
>
> Having said that I am trying to find the way to work AJAX with Struts1
> there is no clear way to do that even though AJAX is just a technology.
>
> Do anyone have any resource in this regards?
>
> Thanks
>
> On 9/10/2010 10:11 AM, Paweł Wielgus wrote:
>> Hi all,
>> the question is if You want to show thousands of records on one page
>> to the user,
>> if yes, thent You need to put them into request or into form,
>> if no then in action put as much as You need into request or form.
>>
>> Best greetings,
>> Paweł Wielgus.
>>
>>
>>
>>
>> 2010/9/10 Anjib Mulepati<an...@hotmail.com>:
>>
>>> One more query suppose "resultList" have thousands of records still is
it
>>> (using request object and putting all result in it) as
>>>
>>> request.setAttribute("resultObjects", resultList);
>>>
>>> the efficeint way to send result to view?
>>>
>>> Any alternative to this?
>>>
>>> Thanks
>>> Anjib
>>>
>>>
>>> On 9/10/2010 9:27 AM, CRANFORD, CHRIS wrote:
>>>
>>>> As others indicated, it's a matter of using the Struts/JSTL tags.
>>>>
>>>> <ul>
>>>> <logic:iterate id="aFoo" name="resultObjects">
>>>> <li><bean:write name="aFoo" property="propertyName"/></li>
>>>> </logic:iterate>
>>>> </ul>
>>>>
>>>> The biggest difference between Struts1 and what what is posted
>>>> below for Struts2 is how you pass the data to the JSP in my
>>>> opinion.
>>>>
>>>> In Struts1, you would still do as you had in your original
>>>> post:
>>>>
>>>> request.setAttribute("resultObjects", resultList);
>>>>
>>>> But instead of using the<% ... %> JSP tags, you would much rather
>>>> using the JSTL, Bean, Logic, Html tag libraries accordingly. They
>>>> will keep your JSP pages clean and much easier to read.
>>>>
>>>> HTH,
>>>> Chris
>>>>
>>>>
>>>>
>>>>> -----Original Message-----
>>>>> From: Anjib [mailto:anjibcs@hotmail.com]
>>>>> Sent: Thursday, September 09, 2010 6:27 PM
>>>>> To: Struts Users Mailing List
>>>>> Subject: Managing code between Action Class and JSP.
>>>>>
>>>>>
>>>>> Yes I am using Struts1.
>>>>>
>>>>> On 9/9/2010 5:10 PM, Greg Lindholm wrote:
>>>>>
>>>>>
>>>>>>> <ul>
>>>>>>> <s:iterator value="%{resultObjects}" var="aFoo">
>>>>>>> <li><s:property value="%{#aFoo.propertyName}" /></li>
>>>>>>> </s:iterator>
>>>>>>> </ul>
>>>>>>>
>>>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>>
>

Managing code between Action Class and JSP.

Posted by Anjib Mulepati <an...@hotmail.com>.
What about doing AJAX call and get result in progression? Isn't this 
will be efficient way?

Having said that I am trying to find the way to work AJAX with Struts1 
there is no clear way to do that even though AJAX is just a technology.

Do anyone have any resource in this regards?

Thanks

On 9/10/2010 10:11 AM, Paweł Wielgus wrote:
> Hi all,
> the question is if You want to show thousands of records on one page
> to the user,
> if yes, thent You need to put them into request or into form,
> if no then in action put as much as You need into request or form.
>
> Best greetings,
> Paweł Wielgus.
>
>
>
>
> 2010/9/10 Anjib Mulepati<an...@hotmail.com>:
>    
>> One more query suppose "resultList" have thousands of records still is it
>> (using request object and putting all result in it) as
>>
>> request.setAttribute("resultObjects", resultList);
>>
>>   the efficeint way to send result to view?
>>
>> Any alternative to this?
>>
>> Thanks
>> Anjib
>>
>>
>> On 9/10/2010 9:27 AM, CRANFORD, CHRIS wrote:
>>      
>>> As others indicated, it's a matter of using the Struts/JSTL tags.
>>>
>>>    <ul>
>>>      <logic:iterate id="aFoo" name="resultObjects">
>>>        <li><bean:write name="aFoo" property="propertyName"/></li>
>>>      </logic:iterate>
>>>    </ul>
>>>
>>> The biggest difference between Struts1 and what what is posted
>>> below for Struts2 is how you pass the data to the JSP in my
>>> opinion.
>>>
>>> In Struts1, you would still do as you had in your original
>>> post:
>>>
>>>    request.setAttribute("resultObjects", resultList);
>>>
>>> But instead of using the<% ... %>    JSP tags, you would much rather
>>> using the JSTL, Bean, Logic, Html tag libraries accordingly.  They
>>> will keep your JSP pages clean and much easier to read.
>>>
>>> HTH,
>>> Chris
>>>
>>>
>>>        
>>>> -----Original Message-----
>>>> From: Anjib [mailto:anjibcs@hotmail.com]
>>>> Sent: Thursday, September 09, 2010 6:27 PM
>>>> To: Struts Users Mailing List
>>>> Subject: Managing code between Action Class and JSP.
>>>>
>>>>
>>>>    Yes I am using Struts1.
>>>>
>>>> On 9/9/2010 5:10 PM, Greg Lindholm wrote:
>>>>
>>>>          
>>>>>> <ul>
>>>>>>    <s:iterator value="%{resultObjects}" var="aFoo">
>>>>>>      <li><s:property value="%{#aFoo.propertyName}" /></li>
>>>>>>    </s:iterator>
>>>>>> </ul>
>>>>>>
>>>>>>              
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>>
>>>        
>>
>>      
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>    


Re: Managing code between Action Class and JSP.

Posted by Paweł Wielgus <po...@gmail.com>.
Hi all,
the question is if You want to show thousands of records on one page
to the user,
if yes, thent You need to put them into request or into form,
if no then in action put as much as You need into request or form.

Best greetings,
Paweł Wielgus.




2010/9/10 Anjib Mulepati <an...@hotmail.com>:
> One more query suppose "resultList" have thousands of records still is it
> (using request object and putting all result in it) as
>
> request.setAttribute("resultObjects", resultList);
>
>  the efficeint way to send result to view?
>
> Any alternative to this?
>
> Thanks
> Anjib
>
>
> On 9/10/2010 9:27 AM, CRANFORD, CHRIS wrote:
>>
>> As others indicated, it's a matter of using the Struts/JSTL tags.
>>
>>   <ul>
>>     <logic:iterate id="aFoo" name="resultObjects">
>>       <li><bean:write name="aFoo" property="propertyName"/></li>
>>     </logic:iterate>
>>   </ul>
>>
>> The biggest difference between Struts1 and what what is posted
>> below for Struts2 is how you pass the data to the JSP in my
>> opinion.
>>
>> In Struts1, you would still do as you had in your original
>> post:
>>
>>   request.setAttribute("resultObjects", resultList);
>>
>> But instead of using the<% ... %>  JSP tags, you would much rather
>> using the JSTL, Bean, Logic, Html tag libraries accordingly.  They
>> will keep your JSP pages clean and much easier to read.
>>
>> HTH,
>> Chris
>>
>>
>>>
>>> -----Original Message-----
>>> From: Anjib [mailto:anjibcs@hotmail.com]
>>> Sent: Thursday, September 09, 2010 6:27 PM
>>> To: Struts Users Mailing List
>>> Subject: Managing code between Action Class and JSP.
>>>
>>>
>>>   Yes I am using Struts1.
>>>
>>> On 9/9/2010 5:10 PM, Greg Lindholm wrote:
>>>
>>>>>
>>>>> <ul>
>>>>>   <s:iterator value="%{resultObjects}" var="aFoo">
>>>>>     <li><s:property value="%{#aFoo.propertyName}" /></li>
>>>>>   </s:iterator>
>>>>> </ul>
>>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Managing code between Action Class and JSP.

Posted by Anjib Mulepati <an...@hotmail.com>.
One more query suppose "resultList" have thousands of records still is 
it (using request object and putting all result in it) as

request.setAttribute("resultObjects", resultList);

  the efficeint way to send result to view?

Any alternative to this?

Thanks
Anjib


On 9/10/2010 9:27 AM, CRANFORD, CHRIS wrote:
> As others indicated, it's a matter of using the Struts/JSTL tags.
>
>    <ul>
>      <logic:iterate id="aFoo" name="resultObjects">
>        <li><bean:write name="aFoo" property="propertyName"/></li>
>      </logic:iterate>
>    </ul>
>
> The biggest difference between Struts1 and what what is posted
> below for Struts2 is how you pass the data to the JSP in my
> opinion.
>
> In Struts1, you would still do as you had in your original
> post:
>
>    request.setAttribute("resultObjects", resultList);
>
> But instead of using the<% ... %>  JSP tags, you would much rather
> using the JSTL, Bean, Logic, Html tag libraries accordingly.  They
> will keep your JSP pages clean and much easier to read.
>
> HTH,
> Chris
>
>    
>> -----Original Message-----
>> From: Anjib [mailto:anjibcs@hotmail.com]
>> Sent: Thursday, September 09, 2010 6:27 PM
>> To: Struts Users Mailing List
>> Subject: Managing code between Action Class and JSP.
>>
>>
>>    Yes I am using Struts1.
>>
>> On 9/9/2010 5:10 PM, Greg Lindholm wrote:
>>      
>>>> <ul>
>>>>    <s:iterator value="%{resultObjects}" var="aFoo">
>>>>      <li><s:property value="%{#aFoo.propertyName}" /></li>
>>>>    </s:iterator>
>>>> </ul>
>>>>          
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>    


RE: Managing code between Action Class and JSP.

Posted by "CRANFORD, CHRIS" <Ch...@setech.com>.
As others indicated, it's a matter of using the Struts/JSTL tags.

  <ul>
    <logic:iterate id="aFoo" name="resultObjects">
      <li><bean:write name="aFoo" property="propertyName"/></li>
    </logic:iterate>
  </ul>

The biggest difference between Struts1 and what what is posted
below for Struts2 is how you pass the data to the JSP in my 
opinion.

In Struts1, you would still do as you had in your original
post:

  request.setAttribute("resultObjects", resultList);

But instead of using the <% ... %> JSP tags, you would much rather
using the JSTL, Bean, Logic, Html tag libraries accordingly.  They
will keep your JSP pages clean and much easier to read.

HTH,
Chris

> -----Original Message-----
> From: Anjib [mailto:anjibcs@hotmail.com]
> Sent: Thursday, September 09, 2010 6:27 PM
> To: Struts Users Mailing List
> Subject: Managing code between Action Class and JSP.
> 
> 
>   Yes I am using Struts1.
> 
> On 9/9/2010 5:10 PM, Greg Lindholm wrote:
> >>
> >> <ul>
> >>   <s:iterator value="%{resultObjects}" var="aFoo">
> >>     <li><s:property value="%{#aFoo.propertyName}" /></li>
> >>   </s:iterator>
> >> </ul>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Managing code between Action Class and JSP.

Posted by Anjib <an...@hotmail.com>.
  Yes I am using Struts1.

On 9/9/2010 5:10 PM, Greg Lindholm wrote:
> I "assumed" from his example that he was using Strut1.
>
> Maybe he could tell us so we don't have to guess and give wrong info.
>
>
> On Thu, Sep 9, 2010 at 4:53 PM, Dale Newfield<da...@newfield.org>  wrote:
>> On 9/9/10 4:12 PM, anjibman wrote:
>>> What I am really struggling in is I have processing result in the form of
>>> List of objects.
>>> What would be the best practice to send such list to JSP ready to grab.
>> Best practice is to store it inside the action, and add a getter to your
>> action that returns the list:
>>
>> public List<Foo>  getResultObjects()
>>
>> Then in the jsp use tags like these:
>>
>> <ul>
>>   <s:iterator value="%{resultObjects}" var="aFoo">
>>     <li><s:property value="%{#aFoo.propertyName}" /></li>
>>   </s:iterator>
>> </ul>
>>
>> The language used inside those %{} is called OGNL (Object Graph Navigation
>> Language).  It can access data held either in a named map (aFoo for example,
>> addressed with a #) or by searching the "value stack" (which typically has
>> the action as the top item, so resultObjects winds up calling your action's
>> getResultObjects() method).
>>
>> http://struts.apache.org/2.2.1/docs/ognl.html
>> http://www.opensymphony.com/ognl/html/LanguageGuide/index.html
>>
>> -Dale
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Managing code between Action Class and JSP.

Posted by Greg Lindholm <gr...@gmail.com>.
I "assumed" from his example that he was using Strut1.

Maybe he could tell us so we don't have to guess and give wrong info.


On Thu, Sep 9, 2010 at 4:53 PM, Dale Newfield <da...@newfield.org> wrote:
> On 9/9/10 4:12 PM, anjibman wrote:
>>
>> What I am really struggling in is I have processing result in the form of
>> List of objects.
>
>> What would be the best practice to send such list to JSP ready to grab.
>
> Best practice is to store it inside the action, and add a getter to your
> action that returns the list:
>
> public List<Foo> getResultObjects()
>
> Then in the jsp use tags like these:
>
> <ul>
>  <s:iterator value="%{resultObjects}" var="aFoo">
>    <li><s:property value="%{#aFoo.propertyName}" /></li>
>  </s:iterator>
> </ul>
>
> The language used inside those %{} is called OGNL (Object Graph Navigation
> Language).  It can access data held either in a named map (aFoo for example,
> addressed with a #) or by searching the "value stack" (which typically has
> the action as the top item, so resultObjects winds up calling your action's
> getResultObjects() method).
>
> http://struts.apache.org/2.2.1/docs/ognl.html
> http://www.opensymphony.com/ognl/html/LanguageGuide/index.html
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Managing code between Action Class and JSP.

Posted by Dale Newfield <da...@newfield.org>.
On 9/9/10 4:12 PM, anjibman wrote:
> What I am really struggling in is I have processing result in the form of
> List of objects.

> What would be the best practice to send such list to JSP ready to grab.

Best practice is to store it inside the action, and add a getter to your 
action that returns the list:

public List<Foo> getResultObjects()

Then in the jsp use tags like these:

<ul>
   <s:iterator value="%{resultObjects}" var="aFoo">
     <li><s:property value="%{#aFoo.propertyName}" /></li>
   </s:iterator>
</ul>

The language used inside those %{} is called OGNL (Object Graph 
Navigation Language).  It can access data held either in a named map 
(aFoo for example, addressed with a #) or by searching the "value stack" 
(which typically has the action as the top item, so resultObjects winds 
up calling your action's getResultObjects() method).

http://struts.apache.org/2.2.1/docs/ognl.html
http://www.opensymphony.com/ognl/html/LanguageGuide/index.html

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Managing code between Action Class and JSP.

Posted by Dave Newton <da...@gmail.com>.
On Thu, Sep 9, 2010 at 4:12 PM, anjibman <an...@hotmail.com> wrote:
> I will try to put in simple way but this may not be complete picture.
>
> What I am really struggling in is I have processing result in the form of
> List of objects. Now if I send this list of objects through request object
> to the JSP I have to do all processing on JSP with scriptlets. What would be
> the best practice to send such list to JSP ready to grab.

The list will be sent as you're sending it now: that's how you get
data to the JSP (view) layer.

The view layer should use either JSTL or custom tags. If there's more
complicated processing than can be handled simply via tags, that
processing should take place on the server side.

I'm not sure what other kind of information you're looking for.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Managing code between Action Class and JSP.

Posted by anjibman <an...@hotmail.com>.
I will try to put in simple way but this may not be complete picture.

What I am really struggling in is I have processing result in the form of
List of objects. Now if I send this list of objects through request object
to the JSP I have to do all processing on JSP with scriptlets. What would be
the best practice to send such list to JSP ready to grab.

 

Dave Newton-6 wrote:
> 
> The scriptlets should be replaced by JSTL/custom tags/etc. Anything
> that can't be trivially implemented using tags should probably happen
> on the server side.
> 
> Other than that, I'm not sure what kind of information you're looking
> for--maybe you could be more specific if you need further help.
> 
> HTH,
> Dave
> 
> On Thu, Sep 9, 2010 at 10:17 AM, anjibman <an...@hotmail.com> wrote:
>>
>> I need the guideline on how to manage data transfer between JSP and
>> action
>> class. I am using delegate in Action class to get an list of object from
>> the
>> server and I have to process then display that list in JSP.
>>
>> Right now I am getting that list as object from server in action class,
>> put
>> it in request object and write scripplets in JSP to process the list in
>> the
>> request object then display it.
>>
>> I don't think it is good practice to put scripplets in JSP. I am not sure
>> where to put those processing part in different class or in Action class
>> itself or its ok in JSP itself.
>>
>> It will be great if anyone can show me with an example to write the code
>> in
>> manageable way.
>>
>> General implementation what I have right now is:
>>
>> Action class
>> Delegate delegateObject;
>> resultList = delegateObject.getResult();
>> request.setAttribute("result",resultList);
>>
>> JSP
>> <%
>>   result = request.getAttribute("result");
>>   for(loop){
>>     //Loop to result and display using html tags.
>>     //e.g. <TD><%= someField %> </TD>
>>   }
>> %>
>>
>> Thanks in advance
>> --
>> View this message in context:
>> http://old.nabble.com/Managing-code-between-Action-Class-and-JSP.-tp29648167p29648167.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Managing-code-between-Action-Class-and-JSP.-tp29648167p29670923.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Managing code between Action Class and JSP.

Posted by Dave Newton <da...@gmail.com>.
The scriptlets should be replaced by JSTL/custom tags/etc. Anything
that can't be trivially implemented using tags should probably happen
on the server side.

Other than that, I'm not sure what kind of information you're looking
for--maybe you could be more specific if you need further help.

HTH,
Dave

On Thu, Sep 9, 2010 at 10:17 AM, anjibman <an...@hotmail.com> wrote:
>
> I need the guideline on how to manage data transfer between JSP and action
> class. I am using delegate in Action class to get an list of object from the
> server and I have to process then display that list in JSP.
>
> Right now I am getting that list as object from server in action class, put
> it in request object and write scripplets in JSP to process the list in the
> request object then display it.
>
> I don't think it is good practice to put scripplets in JSP. I am not sure
> where to put those processing part in different class or in Action class
> itself or its ok in JSP itself.
>
> It will be great if anyone can show me with an example to write the code in
> manageable way.
>
> General implementation what I have right now is:
>
> Action class
> Delegate delegateObject;
> resultList = delegateObject.getResult();
> request.setAttribute("result",resultList);
>
> JSP
> <%
>   result = request.getAttribute("result");
>   for(loop){
>     //Loop to result and display using html tags.
>     //e.g. <TD><%= someField %> </TD>
>   }
> %>
>
> Thanks in advance
> --
> View this message in context: http://old.nabble.com/Managing-code-between-Action-Class-and-JSP.-tp29648167p29648167.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org