• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

ActionForward between 2 differnt web_apps

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Anjali Krishnan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the reply ! I will encode and decode as needed.
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic