You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kishore Subramanian <ki...@agilesoft.com> on 2001/02/07 23:40:38 UTC

Forwarding to the same page

Hi,

Is there a way for an Action class to find out which page/action called it ?
Iam faced with a problem where the Action class should perform its work and forward the page back to callee page.

Note - I cannot add any "forward" tags to this Action mapping because this Action is part of a framework.

Any clues ?

Thanks,
Kishore


Re: Forwarding to the same page

Posted by Martin Cooper <ma...@tumbleweed.com>.
Yes, you are correct, that's where it comes from. It's true that there's no
guarantee that this is where you really came from, but it is where you'll go
back to if your validation fails, and in the vast majority of cases, I would
guess, you want to go back to where you came from to show the errors. ;-)

--
Martin Cooper
Tumbleweed Communications


----- Original Message -----
From: "Mike Campbell" <ug...@unixgeek.com>
To: <st...@jakarta.apache.org>
Sent: Wednesday, February 07, 2001 3:21 PM
Subject: Re: Forwarding to the same page


> >>>>> "MC" == Martin Cooper <ma...@tumbleweed.com> writes:
>
> MC> You can call mapping.getInput() in your Action class. This will
> MC> get you the URI that provided your input, and is what Struts uses
> MC> to send you back to your input form if the ActionForm validation
> MC> fails.
>
> Doesn't getInput() return what struts-config.xml has in the
> "...input=..." part of the <action ...> section?  Or have I
> misunderstood that?



Re: Forwarding to the same page

Posted by Mike Campbell <ug...@unixgeek.com>.
>>>>> "MC" == Martin Cooper <ma...@tumbleweed.com> writes:

MC> You can call mapping.getInput() in your Action class. This will
MC> get you the URI that provided your input, and is what Struts uses
MC> to send you back to your input form if the ActionForm validation
MC> fails.

Doesn't getInput() return what struts-config.xml has in the
"...input=..." part of the <action ...> section?  Or have I
misunderstood that?

Re: Forwarding to the same page

Posted by Martin Cooper <ma...@tumbleweed.com>.
You can call mapping.getInput() in your Action class. This will get you the
URI that provided your input, and is what Struts uses to send you back to
your input form if the ActionForm validation fails.

--
Martin Cooper
Tumbleweed Communications


----- Original Message -----
From: "Kishore Subramanian" <ki...@agilesoft.com>
To: <st...@jakarta.apache.org>
Sent: Wednesday, February 07, 2001 2:40 PM
Subject: Forwarding to the same page


> Hi,
>
> Is there a way for an Action class to find out which page/action called it
?
> Iam faced with a problem where the Action class should perform its work
and forward the page back to callee page.
>
> Note - I cannot add any "forward" tags to this Action mapping because this
Action is part of a framework.
>
> Any clues ?
>
> Thanks,
> Kishore
>



Re: Forwarding to the same page

Posted by Peter Alfors <pe...@irista.com>.
You can use:
    request.getHeader("Referer");
to return the referring page.

Or, we have a class that takes a request object and performs methods against it.
One thing that it does is return the referring page. (without the query string or path).
This is the method from it....

m_request is a member variable of the class...

   public String getReferrer()
   {
       String sFullRef, sRefPlus, sReferer;

       sFullRef = m_request.getHeader("Referer");
       if(sFullRef == null) return "";

       int iPos = sFullRef.lastIndexOf("/");
       if(iPos >= 0) {
         sRefPlus = sFullRef.substring(iPos+1, sFullRef.length());
       }
       else {
         sRefPlus = sFullRef.substring(0, sFullRef.length());
       }

       iPos = sRefPlus.indexOf("?");
       if(iPos >= 0) {
         sReferer = sRefPlus.substring(0, iPos);
       }
       else {
         sReferer = sRefPlus;
       }

       return sReferer;
   } // ends getReferer()

HTH,
    Pete


Kishore Subramanian wrote:

> Hi,
>
> Is there a way for an Action class to find out which page/action called it ?
> Iam faced with a problem where the Action class should perform its work and forward the page back to callee page.
>
> Note - I cannot add any "forward" tags to this Action mapping because this Action is part of a framework.
>
> Any clues ?
>
> Thanks,
> Kishore