• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Redirecting the req to another server ?

 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do i redirect the request from my servlet to a program running in another server ?

I am trying to help out my friend who faces this issue in his college project. He is trying to develop a context based search engine. The servlet in his application is fetching the query the user types and does some manipulations + some business logic, forms a optimized query and is trying to send it to google. We tried using the RequestDispatcher to forward/redirect the request and we failed in succeding.

Is it really possible to forward a request to another server ? Am i making sense here?

Thanks in advance !

Regards,
Arvind
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are looking for response.sendRedirect(url)

Anything to dp with RequestDispatcher must be related to a resource inside the servlet container, you can't redirect or forward to an external resource.

Dave
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is not possiblw with the help of requestdispatcher. Instead you can use JMS. But in that case also if should have access to the Google server. Here the concept of server clustering and caching will come.
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
He should redirect to the following address:

http://www.google.com/search?q=keywords

keywords being the url encoded keywords to search.
 
Arvind Sampath
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You are looking for response.sendRedirect(url)





I tried the above piece of code and failed to redirect again. Can u pls point out where am going wrong?

Regards,
Arvind
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
response.sendRedirect("http://www.google.com");

Forward slashes, not escaped backslashes please
 
Arvind Sampath
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, It doesnt get sillier than this

Thanks David


Regards,
Arvind
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's called the Dilbert Principle: all of us at some stage will do something silly

I've solved the same basic configuration error in my system three times today :roll:
reply
    Bookmark Topic Watch Topic
  • New Topic