Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes forward a request in distributed application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "forward a request in distributed application " Watch "forward a request in distributed application " New topic
Author

forward a request in distributed application

Loveleen Saroya
Ranch Hand

Joined: Aug 08, 2005
Posts: 42
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

Joined: Aug 08, 2005
Posts: 42
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

Joined: Dec 04, 2004
Posts: 950
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


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Loveleen Saroya
Ranch Hand

Joined: Aug 08, 2005
Posts: 42
"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

Joined: Dec 04, 2004
Posts: 950
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

Joined: Aug 08, 2005
Posts: 42
Thanks Narendra.. so when r u plannin to appear for the certification?
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026

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 ]

Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi Loveleen,

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

Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: forward a request in distributed application
 
Similar Threads
how to call JSP from Servlet
When, JSP action forward and redirect to be used?
request attributes
Please help me in JRUN
Forward in an action forms reset method.