You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Synovic, Michael" <mi...@sap.com> on 2001/09/19 22:45:51 UTC

RE: Dynamic forward to jsps

Hey Craig,

Don't know how to implement dynamic forwarding, but based on your example,
you might want to investigate how to build a single JSP to handle multiple
languages, rather than using different JSPs for different languages.

Check out the I18N (internationalization) features of Struts. 

Mike




-----Original Message-----
From: Craig_Reichenbach@lotus.com [mailto:Craig_Reichenbach@lotus.com]
Sent: Tuesday, September 18, 2001 11:44 AM
To: struts-user@jakarta.apache.org
Subject: Dynamic foward to jsps



I have seen some discussion of dynamic forwarding in the archives as it
pertains to passing parameters.  But I haven't seen anything yet that
speaks to how one might have more than 1 "success" page.  For example,
suppose I had menu.jsp and menu_es.jsp and I wanted to dynamically forward
all requests from browsers set to accept Spanish to the Spanish jsp.

Ignoring all  realistic implications & in order to get my question across,
what comes to mind is a dynamic page attribute in struts-config, ie:

<forward name="success"  page="${user.succes.page}">

The value of success.page would then correspond to an entry in the various
properties files, ie:

AppResources.properties contains:
user.success.page=menu.jsp

AppResources_es.properties contains:
user.successpage=menu_es.jsp



The other thought that comes to mind is for the Action class to extract the
locality from the browser or session and then set a String variable
representing the success  or failure page accordingly.   For example:

String success = "success";

if (locale == spanish)
     success = "success_es";

return mapping.findForward( success );

Meanwhile the struts-config contains multiple 'success' forwards:
<forward name="success"  page="menu.jsp">
<forward name="success_es"    page="menu_es.jsp">


This would be pretty weak and unscalable.

I appreciate your thoughts, ideas, & solutions.

Thanks,
Craig