aspose file tools*
The moose likes Servlets and the fly likes can serveltfileter be used for serverside validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "can serveltfileter be used for serverside validation" Watch "can serveltfileter be used for serverside validation" New topic
Author

can serveltfileter be used for serverside validation

Rauhl Roy
Ranch Hand

Joined: Aug 01, 2006
Posts: 401

Hi,

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

May i know what should i do?
thanks and regards,
venkat.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rauhl Roy
Ranch Hand

Joined: Aug 01, 2006
Posts: 401

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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

Oh, listeners...

Well, not really. What type of listener were you thinking of?
Rauhl Roy
Ranch Hand

Joined: Aug 01, 2006
Posts: 401

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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

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

Joined: Aug 01, 2006
Posts: 401

did you mean servlets can validate anything, so i dont have to think of filters and all?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
What exactly do you want to validate? The logged in user? Or certain request headers? Or the submitted input values?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: can serveltfileter be used for serverside validation