• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

can serveltfileter be used for serverside validation

 
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

can serveltlister or servelet filter be used for server side validations?

May i know what should i do?
thanks and regards,
venkat.
 
Marshal
Posts: 67496
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While you could use a filter for server-side anything, including validation, I don't think it's a good idea. Filters are best used for purposes that are orthogonal to the servlets that will be running. In other words, if the servlets depend upon the filter being run in order to execute properly, such as with the validation idea, then what good is it to take that logic out of the servlet and put it in a filter? There are much better ways to share common code (if that's the idea behind it).

I do not know what a servletlister is.
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot for your reply, i did not mean servletlistner i'm sorry, i did mean, listeners in servlets can be used for server side validations?
 
Bear Bibeault
Marshal
Posts: 67496
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, listeners...

Well, not really. What type of listener were you thinking of?
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
even i do not know, but i just want to know, my scenario is that if server side validation gives any error message we are supposed to send a notification or a message to client some times technical staff and sometimes to the server.

please let me know if you are aware of this.
 
Bear Bibeault
Marshal
Posts: 67496
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As listeners are triggered on events that are usually outside the normal request-response cycle, they are unsuitable for this purpose.

Do you have a specific validation need that you are trying to solve that can't simply be handled in the servlet?

Remember, with very few exceptions, simple is better.
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did you mean servlets can validate anything, so i dont have to think of filters and all?
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly do you want to validate? The logged in user? Or certain request headers? Or the submitted input values?
 
Bear Bibeault
Marshal
Posts: 67496
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Filters are good for "out of band" things like authentication, or setting no-cache headers. They should not be used for doing "in-line" things that are better and easier to handle in the servlet itself.
 
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic