Win a copy of Head First Android this week in the Android 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Code implementations for doHead(), doOptions(), doTrace()

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have gone through many sites understanding HEAD, OPTIONS, TRACE, but none of them shown the code implementation of these methods in servlet.
Can someone please share the code implementation part for these methods.

Thank you.
 
Sheriff
Posts: 67595
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
It's actually rare for those to be implemented in most servlets -- what usage are you envisioning using these HTTP methods for? CORS?
 
vishnu priyag
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:It's actually rare for those to be implemented in most servlets -- what usage are you envisioning using these HTTP methods for? CORS?



No, i don't have any specific requirements for implementing, but just want to know how to implement it and test the same to see the response.
 
Bear Bibeault
Sheriff
Posts: 67595
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
Implementing them is as simple as adding the appropriate doXXX methods to the servlet. What goes in the method depends on what you want to do with them.

HEAD is used to return body-less information regarding a resource, OPTIONS is most often used for CORS. TRACE is generally used for debugging.
 
vishnu priyag
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Implementing them is as simple as adding the appropriate doXXX methods to the servlet. What goes in the method depends on what you want to do with them.

HEAD is used to return body-less information regarding a resource, OPTIONS is most often used for CORS. TRACE is generally used for debugging.



I understand about the functionality, but want to know how to write logic for those in servlet methods.
 
Bear Bibeault
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your questions is sort of like:
"I want to build a Thing."
"What is the Thing supposed to do?"
"I dunno, I just want to build it."

If you know how to set response headers, you know how to implement HEAD. Fetch the same information you would fetch for a GET, and just return the headers.

Read up on CORS to see what headers should be returned for a CORS OPTIONS request.

For TRACE:

The HTTP TRACE method is normally used to return the full HTTP request back to the requesting client for proxy-debugging purposes. An attacker can create a webpage using XMLHTTP, ActiveX, or XMLDOM to cause a client to issue a TRACE request and capture the client's cookies.


Note the security vulnerability.
 
You showed up just in time for the waffles! And 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