• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
prash patil
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.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE 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.
 
Michael Angstadt
Ranch Hand
Posts: 278
Eclipse IDE Java PHP
  • 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
Clojure IntelliJ IDE 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: 278
Eclipse IDE Java PHP
  • 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
Clojure IntelliJ IDE 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!
 
giridhar challa
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66153
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!