You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by chamal desilva <ch...@yahoo.com> on 2006/10/03 10:20:59 UTC

Forwarding to a url

Hi,

Is it possible to forward to a url rather than
forwaring to a forward in struts.config file from a
action class.

For example we can do like this from servlets.

req.getRequestDispatcher("page.jsp?id=10").forward(req,resp);

Can we do the same with struts.

Thanking You,
Chamal.

__________________________________________________
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: Forwarding to a url

Posted by Antonio Petrelli <ap...@apache.org>.
chamal desilva ha scritto:
> Thanks Antonio Petrelli,
>
> But I can't define a forward, since the forward url
> and id are not static. URL can be any page and id can
> be any number. Is there a way to do it without
> forwards.
>   

Did you read this line?

* return new ActionForward("page.jsp?id=10");

Compose that string the way that you prefer.

Ciao
Antonio

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


Re: Forwarding to a url

Posted by chamal desilva <ch...@yahoo.com>.
Thanks Antonio Petrelli,

But I can't define a forward, since the forward url
and id are not static. URL can be any page and id can
be any number. Is there a way to do it without
forwards.

Chamal.

--- Antonio Petrelli <ap...@apache.org> wrote:

> chamal desilva ha scritto:
> > Hi,
> >
> > Is it possible to forward to a url rather than
> > forwaring to a forward in struts.config file from
> a
> > action class.
> >
> > For example we can do like this from servlets.
> >
> >
>
req.getRequestDispatcher("page.jsp?id=10").forward(req,resp);
> >
> > Can we do the same with struts.
> >   
> 
> Sure, you can:
> * define a forward inside your action mapping that
> points to an URL:
> <forward name="success" path="page.jsp?id=10" />
> * return a newly created ActionForward at the end of
> the "execute" method:
> return new ActionForward("page.jsp?id=10");
> 
> Anyway, I think that your problem depends on the
> presence of the 
> parameter. Why do you want to process that parameter
> in the JSP page? 
> Isn't it better to process it into the action and
> putting something in 
> request scope?
> 
> Ciao
> Antonio
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 


__________________________________________________
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: Forwarding to a url

Posted by Antonio Petrelli <ap...@apache.org>.
chamal desilva ha scritto:
> Hi,
>
> Is it possible to forward to a url rather than
> forwaring to a forward in struts.config file from a
> action class.
>
> For example we can do like this from servlets.
>
> req.getRequestDispatcher("page.jsp?id=10").forward(req,resp);
>
> Can we do the same with struts.
>   

Sure, you can:
* define a forward inside your action mapping that points to an URL:
<forward name="success" path="page.jsp?id=10" />
* return a newly created ActionForward at the end of the "execute" method:
return new ActionForward("page.jsp?id=10");

Anyway, I think that your problem depends on the presence of the 
parameter. Why do you want to process that parameter in the JSP page? 
Isn't it better to process it into the action and putting something in 
request scope?

Ciao
Antonio

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