• 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

Servlet filter

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all



I am having a doubt with servlet filter.

If a user enters www.google.com in browser i need to intercept the user request using filter and send the reuest through my server and the same if the resoponse comes from the server i need to intercept the response and i want to add something in the response and send the response back to the client..

By using the servlet filter we can do this.But i don know how to redircect the user request to my application server..

I am using apache tomcat and eclipse.

can any one give me an idea..thanks in advance..
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


By using the servlet filter we can do this


No, we can't. A request for www.google.com goes to the server with the IP address that particular URI resolves to, which is not going to be your server.
 
sekar bala
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then what is the way to intercept the request using filters.
 
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 can only deal with requests that get sent to your server. As Paul said, if the request doesn't get sent to your server, then you don't get to do a thing.
 
sekar bala
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ok i agree.suppose if user enters www.google.com i redirect that to my server through proxy again from the proxy server i need to send the request to www.google.com again the same way the reponse.

How to do this one.Any idea?
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats impossible. If you do that it will come under security violation :-)

If you were owning the www.google.com domain you could add an interceptor.

A simplest form of interceptor can be like,

suppose you have an application hosted on your server. You want to log all input requests and outgoing responses from your service.. You can add an interceptor to log the request and response without disturbing your service application.

-Arun
 
sekar bala
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its possible through proxy

for eg:

proxypass //ll.com http://www.google.com

In hosts file we need to define the ll.com.


Now i am able to redirect.But my problem is i am not able to intercept..

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"red force", please check your private messages for an important administrative matter. Thanks.
 
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
Please update your display name if you would like us to help.
At this stage it would be easier if you told us what you were trying to do.
 
sekar bala
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all


Anyone help me..its very urgent..
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What part of "this cannot be done" did you find confusing? There is no way that you can intercept traffic to google or any other site that you do not own the DNS rights to.
 
sekar bala
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not intercepting some others.This is the situation if i am entering google in my browser before it google reaches the server i need to forward that request to my proxy and send it to corresponding server.And again if the response comes from the server first it must come to my proxy server and then i need to add something in that response and send that to server..


This is the one that i want to do.Can you have any idea?
 
Ranch Hand
Posts: 282
Eclipse IDE PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'd have to modify your browser in some way. It's impossible to do this to a random person of your choosing without their permission. You can configure your browser to communicate through a proxy by modifying its settings. For example, in Firefox, go to [Preferences > Advanced > Network > Settings].
 
sekar bala
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont want to do it for random person.I am doing for myself only.

How to do that thing for myself.
 
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
There are several Java based HTTP Proxies available, I suggest grabbing one of these and bending them to your will.
eg http://www.membrane-soa.org/soap-monitor/
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic