You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "salinaale@libero.it" <sa...@libero.it> on 2001/06/19 11:34:12 UTC

forwarding to itself

Hello,
i have one action bean for changing language and the relative mapping 
in Struts-config.xml.
This mapping can be called from many page so i can't 
use "mapping.findForward(mapping.getInput()) !!
How can i do to to forward request to the page which from this request 
comes???

Thanks



Re: forwarding to itself

Posted by Oleg V Alexeev <go...@penza.net>.
Hello salinaale,

Tuesday, June 19, 2001, 1:34:12 PM, you wrote:

sli> Hello,
sli> i have one action bean for changing language and the relative mapping 
sli> in Struts-config.xml.
sli> This mapping can be called from many page so i can't 
sli> use "mapping.findForward(mapping.getInput()) !!
sli> How can i do to to forward request to the page which from this request 
sli> comes???

You can calculate query string for current page

<%
   String sourceURL = null;
   StringBuffer URL = HttpUtils.getRequestURL(request);
   String queryString = request.getQueryString();
   if( (queryString!=null) && (queryString.length()>0) ) {
    URL.append("?");
    URL.append( queryString );
   }
   sourceURL = URL.toString();

%>

for example. But this will work only if you call your page directly
and not use forward from action.
If you use forward (without redirect) then you must calculate path to
redisplay page in action class, store it in request scope and use this
string as parameter for language switch. Language switch action take
this query string and make forward to it after language switching.

-- 
Best regards,
 Oleg                            mailto:gonza@penza.net