Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Forwarding to another application with the request object  RSS feed

 
udhaya kanagaraj
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a doubt in servlet dispatcher. I need to forward to another application from my servlet. But I know if we use response.sendredirect() the request object will be lost. But I need the request object as well in the forwarded page. That is something like the below code. But the below code won't work.



If I use



the request object will be lost.

Please help me to forward to another application with the request object
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need the Request object?

Are you storing any data and expecting in the other servlet/jsp?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
set crossContext =true in your context of application. and use



read the crosscontext attribute Here
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is available in Tomcat, have we got anything similar in any other server.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure . you can try it out,if you have another server
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seetharaman venkatasamy wrote:I am not sure . you can try it out,if you have another server


As I know anything of this sort is not available in Weblogic/Websphere/OracleAS.

Between Udhaya are you trying or expecting a solution wrt Tomcat.
If Yes then whatever seetharaman has said is right.Just follow the document.
 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HttpC.lient will suit for this requirement
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PavanPL KalyanK wrote:HttpC.lient will suit for this requirement


Can you elaborate?
 
udhaya kanagaraj
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for all your reply.

But still my problem is not solved.

I want to do this forward in Weblogic10.3 server. I want to do a switching logic between 2 application after login. but I need to maintain the login information on one of the application based on the switch condition. That is something like the below code

Help me to solve this issue
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Honestly you cann't do that with RequestDispatcher if context has to be shared..
What you can do is to keep a flag to say the user is authenticated in the database.
And have a filter in the other application which retrieves the Login information depending on the flag.
Otherwise throw back to login.

hope this helps...
 
Vinoth Thirunavukarasu
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The bellow link will help you.
Example
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vinoth,

Vinoth Thirunavukarasu wrote:Hi,
The bellow link will help you.
Example


The example says how to dispatch a request to the defined URL within the context(single application).
But here the question is how to set data and dispatch a request to a resource available in other application.

With straight forward its not achievable.



 
Ravindra Verma
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not possible though you can do it by using some tricks (serialization probably), but still it shows flaws in your design. Inter communication should be based on request parameters only, other application should not be waiting for whole request object.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi udhaya,

Then use QueryString
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seetharaman venkatasamy wrote:Hi udhaya,

Then use QueryString


How secure it will be to use querystring, If I need to pass my login details...
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohamed Inayath wrote:
How secure it will be to use querystring, If I need to pass my login details...


Cool. Encrypt it . it is not a bad idea ,when you try to redirect to a different Application
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seetharaman venkatasamy wrote:
Cool. Encrypt it . it is not a bad idea ,when you try to redirect to a different Application


Yes, we can encrypt the data before we send putting aside the limitation we have with the content length.

otherwise feasible...
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seetharaman venkatasamy wrote:
Cool. Encrypt it . it is not a bad idea ,when you try to redirect to a different Application


Yes, we can encrypt the data before we send putting aside the limitation we have with the content length.

otherwise feasible...

Between; Udhaya could you please explain what exactly your business requirement is?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!