aspose file tools*
The moose likes Servlets and the fly likes is this possible Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "is this possible" Watch "is this possible" New topic
Author

is this possible

John Dunn
slicker
Ranch Hand

Joined: Jan 30, 2003
Posts: 1108
I'm currently using a servlet that opens a URLConnection and does an inquiry/request to a new server. The calling servlet passes any info to the client.

What I'd rather to is have the client call servlet A, servlet A call/redirect/forward to servlet B (different server), which will process data & return results to a client.

Is this possible?


"No one appreciates the very special genius of your conversation as the dog does."
dema rogatkin
Ranch Hand

Joined: Oct 09, 2002
Posts: 294
response.sendRedirect should do the job.


Tough in space?, <a href="http://tjws.sf.net" target="_blank" rel="nofollow">Get J2EE servlet container under 150Kbytes here</a><br />Love your iPod and want it anywhere?<a href="http://mediachest.sf.net" target="_blank" rel="nofollow">Check it here.</a><br /><a href="http://7bee.j2ee.us/book/Generics%20in%20JDK%201.5.html" target="_blank" rel="nofollow">Curious about generic in Java?</a><br /><a href="http://7bee.j2ee.us/bee/index-bee.html" target="_blank" rel="nofollow">Hate ant? Use bee.</a><br /><a href="http://7bee.j2ee.us/addressbook/" target="_blank" rel="nofollow">Need contacts anywhere?</a><br /><a href="http://searchdir.sourceforge.net/" target="_blank" rel="nofollow">How to promote your business with a search engine</a>
John Dunn
slicker
Ranch Hand

Joined: Jan 30, 2003
Posts: 1108
doesn't sendRedirect just make the client make a second call? Is there a way I can do this without the client even knowing?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by John Dunn:
doesn't sendRedirect just make the client make a second call? Is there a way I can do this without the client even knowing?


No.
Even with sendRedirect, you could run into issues under SSL if you're using. Browsers (correctly) alert the user if a request is being made to a domain that is different from the one they originally established the secure connection with.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18141
    
    8

If you redirect to a URL on this other server, then what the person looking at the browser will see in the address bar, after that happens, is that other URL. If you don't want them to see that URL, for whatever reason, then your options are limited.

You can't forward to a URL outside your application. So if you don't want to redirect, you're limited to the setup you have now, namely to do the URLConnection yourself. Bear in mind that if what the other server returns includes links (e.g. images), those links may be relative to the other server's URL and hence wouldn't work with your server's URL. You would have to fiddle with them to make them absolute links.
John Dunn
slicker
Ranch Hand

Joined: Jan 30, 2003
Posts: 1108
I'm not using a browser, per se. Client app has a built in IE browser client. I basically get an xml inquiry, parse, do some lookups based on fields. If I determine the inquiry is of type "A" or "B", (instead of "C", "D", "E"), I update a few fields, add a few fields and resend the altered inquiry to another system and WAIT for a response. Response gets sent back unaltered to the client.

I'd like to get an inquiry, parse, do the lookups, and if I determine type "A" or "B", forward/redirect the altered inquiry to the other system and let that system return to the client. In my case the "other" system is on another host, behind the firewall but still another host.

=====================

Perhaps, what I need to do in this scenerio is to return the altered inquiry to the client and be done with it, letting them make the second call on their own.
kasu ji
Greenhorn

Joined: Jan 25, 2006
Posts: 3
Originally posted by John Dunn:
I'm currently using a servlet that opens a URLConnection and does an inquiry/request to a new server. The calling servlet passes any info to the client.

What I'd rather to is have the client call servlet A, servlet A call/redirect/forward to servlet B (different server), which will process data & return results to a client.

Is this possible?





you have to activate servlet chaining.it is easy if u can use the java web server provided by java soft.
in that the manage tab
u are allowed to instantiate the servlet chaining.
the servlets will be seperated with commas
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Servlet chaining is an outdated feature that you won't find in modern containers. You can get similar results with requestDispatchers.

Still this doesn't help the user who is talking about resources in another server.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: is this possible
 
Similar Threads
Buffering in Jsp
Push Registry with socket or datagram connections
Server pushing of a JSP
RMI and servlet communication
Java n Xml