• Post Reply Bookmark Topic Watch Topic
  • New Topic

Request Dispatcher Question

 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

hwo can i pass a request in one context to a different context

Regards
A Kumar
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
assuming you want it all done on the server, both contexts need to be in the same container, you need to get a request dispatcher for the other context, and the other context needs to be set to allow context sharing. By default this is not allowed since it would allow contexts to be insecure by letting them communicate and thus spy on each other.

You'll need to look at the settings for your container to see how to set this property.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose i have to send the request to an external server context ...then how??

I am using websphere server...
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No can do. You'll need to generate a new request to the remote server.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No can do. You'll need to generate a new request to the remote server.


how do we do it in the servlet???
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think we're up to the point where you'll need to tell us what you're trying to do. I can think of options, but it would help to know some details first.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its like a request hits a servlet in a web application ..that does some logic and then the result of this has to be sent as input to another servlet but in a different context ....

now how to do this...

I tried RequestDispatcher but was not successful...
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does the client send this information to server 2, or does server 1?
Is the data sensitive?
Do you control server 1 and server 2(ie if required could you deploy code or changes to both)?
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does the client send this information to server 2, or does server 1?

server 1

Is the data sensitive?

Yes

Do you control server 1 and server 2(ie if required could you deploy code or changes to both)?


server1
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Bear mentioned in an earlier post, the best you can do then is a new Http request from your Servlet on Server1 to Servlet on Server2
Take a look at HttpURLConnection and if your request is complicated (like say you wish to send cookies), take a look at Apache commons HttpClient.

cheers,
ram.
[ August 18, 2007: Message edited by: ramprasad madathil ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!