• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in forwarding a request

 
rahul lahiri
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was using the following code to redirect a request

response.sendRedirect("http://www.google.com");

Yet, when I forward the request like the follwing

rd=request.getRequestDispatcher()
rd.forward("http://www.google.com");

it is taking the relative url....that is my context root is getting appended with the url.Is there a way to fix this?Basically I dont want the url to change.hats why I was using a forward instead of a redirect.Is there any other way of achieving this?

thank you in advance
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot forward to a URL outside of your web application -- it makes no sense at all. What are you actually trying to achieve?
 
rahul lahiri
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah.I know it might seem a bit weired but I want hide the page url so that if the url is checked by a filter, I can by pass it.Is there any other way of doing this inside a servlet?Any ways, thanks to you for replying.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to create a proxy to get around a firewall or ip filter like iPrism?
If so, there are a lot more issues that you will need to consider.

Remember web pages are made up of lots of resources (images, js pages, css sheets, etc...).
Each of these is fetched by the browser after the initial HTML is downloaded and parsed.
If you try to stream a page from another server through your app, you will also need to rewrite the HTML to change all of the URLs for these resources.

If you're trying to do something else, let us know what it is and we might be able to help.
 
rahul lahiri
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah.I was exactly trying to do that.Could you give me some information about some tools which are available for achieving this?And the one you have named,iPrism,could you give me some information about that?
thanks in advance
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iPrism is a commercial product for filtering web content.
It's used a lot in schools and high security environments where we access needs to be restricted.
A Google search should find their home page pretty quickly.

As far as building a proxy goes, I've never done it but I can tell it would be a bit of work.
Like I said earlier, if you want to completely trick the network you're on into thinking that everything is coming from your site, you would need to parse any text files, and rewrite any URLs that point to the other server. This includes hyperlinks as well.
If the external site always uses relative links, it would be a little easier but you can't count on that.

If I were doing this, I would start by Googling around to see if there are any existing open source projects out there for doing this.

-Ben

PS: This topic is getting close to being out of my comfort zone.
Javaranch isn't here to help people who are hacking sites or networks.
What is the reason that you are trying to this?
 
rahul lahiri
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your information.Actually while I was learning forward and redirect topics,it came to my mind that any one who knew a bit about programming, could bypass a filter.That is why I was testing with the forward to see if I could go to an external url.But now I see that there is a lot of work to be done and its not easy for a novice to achieve this.Anyways,thanks again for your information.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic