Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to block the requst coming from doDelet,doTrace,doOption method

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

I have one scenario where I need help.

In my application I want to block the request coming from doDelet,doTrace,doOption method.
i.e allow only doGet and doPost.

I am searching in direction using ServletFilters but not able to get the method name using request object in doFilter () method..

Your help is greatly appriciate..


Regards,
PP.
 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What would happen, if we override only doGet() and doPost() methods? Then the servlet won't support other HTTP methods.
 
Ranch Hand
Posts: 282
Eclipse IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Container returns an error response (HTTP 501 I think) when the servlet does not have a do*() method to match the method in the request. For example, if the servlet does not have a doDelete() method, then any DELETE requests to that servlet will return an HTTP error.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Michael Angstadt wrote:The Container returns an error response (HTTP 501 I think) when the servlet does not have a do*() method to match the method in the request. For example, if the servlet does not have a doDelete() method, then any DELETE requests to that servlet will return an HTTP error.


I also think so, and we can redirect it to a error page! Can't we?
 
Michael Angstadt
Ranch Hand
Posts: 282
Eclipse IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Abimaran Kugathasan wrote:I also think so, and we can redirect it to a error page! Can't we?



Yep. You would have to add some tags to your deployment descriptor to tell it to load a particular JSP page when a 501 error occurs. You would also have to label that JSP page as an error page by adding the "isErrorPage" attribute to the JSP's page directive and setting the value of that attribute to "true".
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Michael Angstadt wrote:
Yep. You would have to add some tags to your deployment descriptor to tell it to load a particular JSP page when a 501 error occurs. You would also have to label that JSP page as an error page by adding the "isErrorPage" attribute to the JSP's page directive and setting the value of that attribute to "true".



Agreed! Thanks!
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess HTML form tag only allows get and post methods right? How can we test the doDelete(), doOptions() methods? Would you please let me know. I never overriden these methods. So I would like to know the test code for this functionality. Thank you.
 
Marshal
Posts: 67414
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ajax, or issue your own HTTP requests from Java code. The HttpClient project may be helpful, or you can roll your own with the classes in java.net.
 
giridhar challa
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Understood. Thanks Bear Bibeault.

 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic