You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Van Henreich Rontal <va...@yahoo.com> on 2005/08/26 17:47:21 UTC

Executing java code w/out forwarding to another page

Hi,

I'm not sure if this has been tackled already or it's
a feature available to Struts cause I don't think it
is normally use.

I have all these messages on a webpage and at a
certain point in time, I want to abort the generation
of these messages so i press an abort button. I would
then need some java code to be executed for cleanup. I
thought of placing it inside a struts action class,
but the problem with that is that in needs a forward
page, but I would not want my messages in the the
current page to be lost they'll be replaced with the
new forward page. Any idea how to get away with these?
I've thought of caching them. One way is to pass
messages on the request or session objects, which I
doubt if it is efficient enough cause there might be a
lot of these messages, or is it just ok and it's not
really inefficient?

I tried returning a "null" instead of an ActionForward
on the Action's execute() method, but the webpage
generates an error. Any suggestions? 

Thanks a lot.




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: Executing java code w/out forwarding to another page

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Thanks for pointing out AjaxTags... I think it might indeed be a decent 
answer in this case.

However, I'd like to point out that the Struts-specific version of 
AjaxTags referenced here is no longer being developed.  There is now a 
non-Struts-specific version which is a part of Java Web Parts 
(http://javawebparts.sourceforge.net).  This version, in addition to not 
being tied to Struts at all, is more flexible and powerful than the 
original version.  I highly suggest anyone thinking of using this 
approach look at that version.  Just go to the above web site and click 
on the Javadocs link, then head to the AjaxTags package in the taglib 
package.  The package summary should do a decent job of getting someone 
familiar with it.

It should also be mentioned that there is now a separate AjaxTags 
project that IS NOT the same as my AjaxTags... the authors of that 
project were less than cooperative in dealing with the conflicting name, 
so I now feel obliged to point out and differentiate whenever either is 
brought up :)

Frank

Sudhaker Raj wrote:
> When you return null from any Action class execute method, that tells
> framework not to bother about doing any forward or include or
> anything. This means you need to handle the response by yourself.
> Something like...
> 
> response.setContentType("text/plain");
> response.getWriter().write("Bingo, you got it.");
> 
> Since you are not doing anything to handle the response, you will get errors. 
> 
> Like I said in my last mail, you need AJAX to do something without
> reloading the page. Check these:
> 
> http://struts.sourceforge.net/ajaxtags/index.html
> http://openrico.org/rico/home.page
> 
> 
> On 8/26/05, Sudhaker Raj <su...@gmail.com> wrote:
> 
>>U need AJAX to rescue you.
>>
>>On 8/26/05, Van Henreich Rontal <va...@yahoo.com> wrote:
>>
>>>Hi,
>>>
>>>I'm not sure if this has been tackled already or it's
>>>a feature available to Struts cause I don't think it
>>>is normally use.
>>>
>>>I have all these messages on a webpage and at a
>>>certain point in time, I want to abort the generation
>>>of these messages so i press an abort button. I would
>>>then need some java code to be executed for cleanup. I
>>>thought of placing it inside a struts action class,
>>>but the problem with that is that in needs a forward
>>>page, but I would not want my messages in the the
>>>current page to be lost they'll be replaced with the
>>>new forward page. Any idea how to get away with these?
>>>I've thought of caching them. One way is to pass
>>>messages on the request or session objects, which I
>>>doubt if it is efficient enough cause there might be a
>>>lot of these messages, or is it just ok and it's not
>>>really inefficient?
>>>
>>>I tried returning a "null" instead of an ActionForward
>>>on the Action's execute() method, but the webpage
>>>generates an error. Any suggestions?
>>>
>>>Thanks a lot.
>>>
>>>
>>>
>>>
>>>__________________________________________________
>>>Do You Yahoo!?
>>>Tired of spam?  Yahoo! Mail has the best spam protection around
>>>http://mail.yahoo.com
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
> 
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


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


Re: Executing java code w/out forwarding to another page

Posted by Sudhaker Raj <su...@gmail.com>.
When you return null from any Action class execute method, that tells
framework not to bother about doing any forward or include or
anything. This means you need to handle the response by yourself.
Something like...

response.setContentType("text/plain");
response.getWriter().write("Bingo, you got it.");

Since you are not doing anything to handle the response, you will get errors. 

Like I said in my last mail, you need AJAX to do something without
reloading the page. Check these:

http://struts.sourceforge.net/ajaxtags/index.html
http://openrico.org/rico/home.page


On 8/26/05, Sudhaker Raj <su...@gmail.com> wrote:
> U need AJAX to rescue you.
> 
> On 8/26/05, Van Henreich Rontal <va...@yahoo.com> wrote:
> > Hi,
> >
> > I'm not sure if this has been tackled already or it's
> > a feature available to Struts cause I don't think it
> > is normally use.
> >
> > I have all these messages on a webpage and at a
> > certain point in time, I want to abort the generation
> > of these messages so i press an abort button. I would
> > then need some java code to be executed for cleanup. I
> > thought of placing it inside a struts action class,
> > but the problem with that is that in needs a forward
> > page, but I would not want my messages in the the
> > current page to be lost they'll be replaced with the
> > new forward page. Any idea how to get away with these?
> > I've thought of caching them. One way is to pass
> > messages on the request or session objects, which I
> > doubt if it is efficient enough cause there might be a
> > lot of these messages, or is it just ok and it's not
> > really inefficient?
> >
> > I tried returning a "null" instead of an ActionForward
> > on the Action's execute() method, but the webpage
> > generates an error. Any suggestions?
> >
> > Thanks a lot.
> >
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> 


-- 
Cheers,
Sudhaker Raj
http://thej2ee.com

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


Re: Executing java code w/out forwarding to another page

Posted by Sudhaker Raj <su...@gmail.com>.
U need AJAX to rescue you.

On 8/26/05, Van Henreich Rontal <va...@yahoo.com> wrote:
> Hi,
> 
> I'm not sure if this has been tackled already or it's
> a feature available to Struts cause I don't think it
> is normally use.
> 
> I have all these messages on a webpage and at a
> certain point in time, I want to abort the generation
> of these messages so i press an abort button. I would
> then need some java code to be executed for cleanup. I
> thought of placing it inside a struts action class,
> but the problem with that is that in needs a forward
> page, but I would not want my messages in the the
> current page to be lost they'll be replaced with the
> new forward page. Any idea how to get away with these?
> I've thought of caching them. One way is to pass
> messages on the request or session objects, which I
> doubt if it is efficient enough cause there might be a
> lot of these messages, or is it just ok and it's not
> really inefficient?
> 
> I tried returning a "null" instead of an ActionForward
> on the Action's execute() method, but the webpage
> generates an error. Any suggestions?
> 
> Thanks a lot.
> 
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.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


Re: Executing java code w/out forwarding to another page

Posted by Martin Gainty <mg...@hotmail.com>.
Basically reconfiguring log4j to switch logs based upon initial eval of 
log4j.xml and then re-evaluation of <set of> conditions later on
for Log4j re-configuration example take a look at
http://marc.theaimsgroup.com/?l=log4j-user&m=107834480407921&w=2

Martin-
----- Original Message ----- 
From: "Van Henreich Rontal" <va...@yahoo.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>; "Martin Gainty" 
<mg...@hotmail.com>
Sent: Friday, August 26, 2005 12:13 PM
Subject: Re: Executing java code w/out forwarding to another page


> Thanks for the reply. I'm trying to debug a machine
> remotely for 10 minutes and set-up a streaming
> connection. I get all those debug messages through the
> stream.
>
> I'm not familiar with log4j, but base on what you're
> saying it needs variable assignment within my app's
> context, so i guess that means a java code? It's what
> I'm trying to achieve, execute some java code, but
> it's only through calling a Struts path(then execute()
> method) that i could think of.
>
>
> --- Martin Gainty <mg...@hotmail.com> wrote:
>
>>
>> Who/what is/are generating the messages?
>> (Im thinking that if you have capability to
>> communicate with generator
>> perhaps you can cut it off at the source)
>> If its logging I know log4j has capabilities to
>> redirect from console to
>> socket to file based on variable assignments within
>> your app's context
>> ?
>> Martin-
>> ----- Original Message ----- 
>> From: "Van Henreich Rontal" <va...@yahoo.com>
>> To: <us...@struts.apache.org>
>> Sent: Friday, August 26, 2005 11:47 AM
>> Subject: Executing java code w/out forwarding to
>> another page
>>
>>
>> > Hi,
>> >
>> > I'm not sure if this has been tackled already or
>> it's
>> > a feature available to Struts cause I don't think
>> it
>> > is normally use.
>> >
>> > I have all these messages on a webpage and at a
>> > certain point in time, I want to abort the
>> generation
>> > of these messages so i press an abort button. I
>> would
>> > then need some java code to be executed for
>> cleanup. I
>> > thought of placing it inside a struts action
>> class,
>> > but the problem with that is that in needs a
>> forward
>> > page, but I would not want my messages in the the
>> > current page to be lost they'll be replaced with
>> the
>> > new forward page. Any idea how to get away with
>> these?
>> > I've thought of caching them. One way is to pass
>> > messages on the request or session objects, which
>> I
>> > doubt if it is efficient enough cause there might
>> be a
>> > lot of these messages, or is it just ok and it's
>> not
>> > really inefficient?
>> >
>> > I tried returning a "null" instead of an
>> ActionForward
>> > on the Action's execute() method, but the webpage
>> > generates an error. Any suggestions?
>> >
>> > Thanks a lot.
>> >
>> >
>> >
>> >
>> > __________________________________________________
>> > Do You Yahoo!?
>> > Tired of spam?  Yahoo! Mail has the best spam
>> protection around
>> > http://mail.yahoo.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
>>
>>
>
>
>
>
> ____________________________________________________
> Start your day with Yahoo! - make it your home page
> http://www.yahoo.com/r/hs
>
>
> ---------------------------------------------------------------------
> 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: Executing java code w/out forwarding to another page

Posted by Van Henreich Rontal <va...@yahoo.com>.
Thanks for the reply. I'm trying to debug a machine
remotely for 10 minutes and set-up a streaming
connection. I get all those debug messages through the
stream. 

I'm not familiar with log4j, but base on what you're
saying it needs variable assignment within my app's
context, so i guess that means a java code? It's what
I'm trying to achieve, execute some java code, but
it's only through calling a Struts path(then execute()
method) that i could think of. 


--- Martin Gainty <mg...@hotmail.com> wrote:

> 
> Who/what is/are generating the messages?
> (Im thinking that if you have capability to
> communicate with generator 
> perhaps you can cut it off at the source)
> If its logging I know log4j has capabilities to
> redirect from console to 
> socket to file based on variable assignments within
> your app's context
> ?
> Martin-
> ----- Original Message ----- 
> From: "Van Henreich Rontal" <va...@yahoo.com>
> To: <us...@struts.apache.org>
> Sent: Friday, August 26, 2005 11:47 AM
> Subject: Executing java code w/out forwarding to
> another page
> 
> 
> > Hi,
> >
> > I'm not sure if this has been tackled already or
> it's
> > a feature available to Struts cause I don't think
> it
> > is normally use.
> >
> > I have all these messages on a webpage and at a
> > certain point in time, I want to abort the
> generation
> > of these messages so i press an abort button. I
> would
> > then need some java code to be executed for
> cleanup. I
> > thought of placing it inside a struts action
> class,
> > but the problem with that is that in needs a
> forward
> > page, but I would not want my messages in the the
> > current page to be lost they'll be replaced with
> the
> > new forward page. Any idea how to get away with
> these?
> > I've thought of caching them. One way is to pass
> > messages on the request or session objects, which
> I
> > doubt if it is efficient enough cause there might
> be a
> > lot of these messages, or is it just ok and it's
> not
> > really inefficient?
> >
> > I tried returning a "null" instead of an
> ActionForward
> > on the Action's execute() method, but the webpage
> > generates an error. Any suggestions?
> >
> > Thanks a lot.
> >
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.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
> 
> 



		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 

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


Re: Executing java code w/out forwarding to another page

Posted by Martin Gainty <mg...@hotmail.com>.
Who/what is/are generating the messages?
(Im thinking that if you have capability to communicate with generator 
perhaps you can cut it off at the source)
If its logging I know log4j has capabilities to redirect from console to 
socket to file based on variable assignments within your app's context
?
Martin-
----- Original Message ----- 
From: "Van Henreich Rontal" <va...@yahoo.com>
To: <us...@struts.apache.org>
Sent: Friday, August 26, 2005 11:47 AM
Subject: Executing java code w/out forwarding to another page


> Hi,
>
> I'm not sure if this has been tackled already or it's
> a feature available to Struts cause I don't think it
> is normally use.
>
> I have all these messages on a webpage and at a
> certain point in time, I want to abort the generation
> of these messages so i press an abort button. I would
> then need some java code to be executed for cleanup. I
> thought of placing it inside a struts action class,
> but the problem with that is that in needs a forward
> page, but I would not want my messages in the the
> current page to be lost they'll be replaced with the
> new forward page. Any idea how to get away with these?
> I've thought of caching them. One way is to pass
> messages on the request or session objects, which I
> doubt if it is efficient enough cause there might be a
> lot of these messages, or is it just ok and it's not
> really inefficient?
>
> I tried returning a "null" instead of an ActionForward
> on the Action's execute() method, but the webpage
> generates an error. Any suggestions?
>
> Thanks a lot.
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.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