• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

forward a request in distributed application

 
Loveleen Saroya
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to forward a request(which contains a bean) using requestdispatcher to a different server running on other machine.

Loveleen Saroya
(SCJP 1.4)
SCWCD in progress
 
Loveleen Saroya
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have to serialize the bean and the request object beside that what else i have to do can u explain with simple code.

Loveleen
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How to forward a request(which contains a bean) using requestdispatcher to a different server running on other machine.


I think you have set the attrribute (bean) in request scope and forwarding it to another resource in the same application in distributed environment. In this case, you can serialize the bean, but not required. The container takes care of it to provide the bean to the right instance where the request is processed.

I don't understand the term "diff server running on other machine". Is the application is running in clustered environment ? or the target application is totally diff application ?

Thanks
 
Loveleen Saroya
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"diff server running on other machine".
lets say from tomcat i want to send it to weblogic on different jvm(same application)
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

lets say from tomcat i want to send it to weblogic on different jvm(same application)


According to me, in your case it is not distributed application, but the same application is running on diff. servers independently. So there is no question of request re-sheduling / load balancing etc. Still we can pass the bean set in request scope as attribute without serialization using request dispatcher.

Try getServletContext().getContext(uripath) to get the Context of another application and then use requestDispatcher on this context. But the getContext() method can return null for security reasons.

Refer Severlet API of ServletContext for more details on this method.

Hope it helps you.
 
Loveleen Saroya
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Narendra.. so when r u plannin to appear for the certification?
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Try getServletContext().getContext(uripath) to get the Context of another application and then use requestDispatcher on this context. But the getContext() method can return null for security reasons.


This doesn't work with tomcat inspite of making the necessary configuration changes. You can try with commercial application servers. I heard people telling inter-context forwarding is working fine with Weblogic.
[ November 16, 2005: Message edited by: Vishnu Prakash ]
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Loveleen,

I had purchaced the voucher, but not yet finalized the date.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic