Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Understood. Thanks Bear Bibeault.

 
Legend has it that if you rub the right tiny ad, a genie comes out.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic