Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple use cases for servlet filters ?  RSS feed

 
Ali Gordon
Ranch Hand
Posts: 182
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, can someone please suggest some simple use cases for servlet filters other than tracking requests ? I was thinking of using a filter to filter out offensive language from entered text. Would that be a good use case ?

Chenqui.
 
Amar Saikia
Ranch Hand
Posts: 43
2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Filter is used generally to filter the Requests before it access the intended business logic. Say if you have a Home servlet and you want only loggedin users to access the servlet, you can use filter to check all the incoming Requests. In your case, I think a validator will do. IMO, Filter should be used in a context with the whole application not in the context of one page. So I will prefer to use a validator instead of a Filter in this case.
 
Ron McLeod
Saloon Keeper
Posts: 1429
207
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jagshemash!

You might use a filter on the request to perform some special kind of authentication/authorization work, or sanitize parameters or decrypt a secure payload from the client. With the response, you could might want to compress the content before sending it to the network or add some special headers.

Ron
 
Ali Gordon
Ranch Hand
Posts: 182
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ryan gadhkov wrote:Filter is used generally to filter the Requests before it access the intended business logic. Say if you have a Home servlet and you want only loggedin users to access the servlet, you can use filter to check all the incoming Requests. In your case, I think a validator will do. IMO, Filter should be used in a context with the whole application not in the context of one page. So I will prefer to use a validator instead of a Filter in this case.


Please tell me what is a validator. Is it just a pojo or method ?
 
Ali Gordon
Ranch Hand
Posts: 182
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron McLeod wrote:Jagshemash!

You might use a filter on the request to perform some special kind of authentication/authorization work, or sanitize parameters or decrypt a secure payload from the client. With the response, you could might want to compress the content before sending it to the network or add some special headers.

Ron


Is there a code examples for this ?
Thank you ron, I like you. Chenqui.
 
Amar Saikia
Ranch Hand
Posts: 43
2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it just a pojo or method ?
I would make it a method in an utility POJO class so that the code can be re used for validating other Requests, if required.
 
Chan Ag
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Chenqui", "Jagshemash"...

Mind translating those? I couldn't understand the meaning of those words. Is that a way of greeting people in some language? Is 'Chenqui' your name?

 
Ron McLeod
Saloon Keeper
Posts: 1429
207
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something like ...

Chenqui - Thanks for listening / Thanks for your time
Jagshemash - How are you?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's stick to English please as per forum policy.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!