• 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

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.
 
Story like this gets better after being told a few times. Or maybe it's just a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!