• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please anybody? RequestDispatcher ?

 
Vilas Lawande
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to forword request to "http://abc.com"
Code is:

RequestDispatcher rd=request.getRequestDispatcher("http://abc.com");
rd.forward(request,response);

but it forword to http://localhost:8080/demo/http://abc.com

here I don't want context path.
How to acieve this??
Please elaborate.......

Regards,
Vilas Lawande
[ January 25, 2008: Message edited by: Vilas Lawande ]
 
Lavanya Mothilal
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vilas,

RequestDispatcher is used to forward a request to any part of your webapp.So you cant forward a request from your webapp to a completely different url .
 
Krishna Srinivasan
Ranch Hand
Posts: 1876
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use response.sendRedirect() for redirecting to the new domain or another server.
 
Vilas Lawande
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
good answer,
but I want forward in such a way that name of forwarded url should not displayed in address bar.

Any body plesase elaborate..

Regards,
Vilas Lawande
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Obviously response.sendredirect() redirects the request to the client and from thereon it would be treated as a fresh request.

If you don't want the url to be reflecting the change, i am not very sure how you may achieve it.

You may consider using Apache HTTP Server wherein you can write a redirect rule for a specific URL/query string to get mapped to a different URL.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can look into a solution that involves frames. I believe you can change the url for an inner frame all you want without it reflected in the browser url. A lot of sites (about.com, google image search, ...) do something like this so they can add a "header" to the page containing their own content. You could do something similar without the header frame.

Is this for hypothetical SCWCD studies or is this something for work?
[ January 25, 2008: Message edited by: Marc Peabody ]
 
Vilas Lawande
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ,
Marc Peabody

Yeah,It is for work purpose.

Regards,
Vilas Lawande
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic