GeeCON Prague 2014*
The moose likes Struts and the fly likes ActionForward between 2 differnt web_apps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ActionForward between 2 differnt web_apps" Watch "ActionForward between 2 differnt web_apps" New topic
Author

ActionForward between 2 differnt web_apps

Anjali Krishnan
Greenhorn

Joined: May 02, 2006
Posts: 7
I want to forward from 1 web_app to another and then return back to the first app. Before forwarding I store all the data in appsA page in the session.

from web_app A --> I am passing a variable called returnTo
this variable has the URL that the second app needs to return to after processing
from web_app appA to web_app appB
ActionForward :
http://localhost:8080/webapp/web_app/appB/initreadB.do?name=test&returnTo=http://localhost:8080/webapp/appA/initappa.do

In appB after processing is done, will forward to the url in returnTo

I would like to know if this approach is correct?
Thanks,
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Your approach is good, but there's one problem you need to solve. Your "returnTo" parameter contains characters that are "unsafe" to pass as a parameter in a URL. You will therefore need to encode it like this:

returnTo = java.net.URLEncoder.encode(returnTo, "UTF-8");

Once encoded, this information can be passed as a parameter in a URL.


Merrill
Consultant, Sima Solutions
Anjali Krishnan
Greenhorn

Joined: May 02, 2006
Posts: 7
Thanks a lot for the reply ! I will encode and decode as needed.
Shilpa Tendulkar
Ranch Hand

Joined: Jul 29, 2001
Posts: 75
Originally posted by Merrill Higginson:
Your approach is good, but there's one problem you need to solve. Your "returnTo" parameter contains characters that are "unsafe" to pass as a parameter in a URL. You will therefore need to encode it like this:

returnTo = java.net.URLEncoder.encode(returnTo, "UTF-8");

Once encoded, this information can be passed as a parameter in a URL.


Question to Merill: Can "returnTo" variable not be passed as hidden? instead of passing in query string. Which could be the best approach?


SCJP5
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Yes, either approach will work as long as the URL is encoded. I tend to favor using the ActionForward approach since the value has to be encoded before it is sent.
 
GeeCON Prague 2014
 
subject: ActionForward between 2 differnt web_apps