Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Two questions

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
1. I have seen several methods return objects of interface types. e.g. getHeaderNames() returns an object of Enumeration type. How is such an object created in the implementation of the setHeaderNames() method by the servlet container? Enumeration, as we know, is an interface not a class?
2. How can we send a header request to a servlet? I guess we can only send Get and Post requests through HTML? How about Head, Put and Delete?
Then what's the use of doXXX methods with Head, Put and Delete?
Thanks in advance.
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Dinesh,
1. Container always implement interfaces like Enumeration, HttpServletrequest, HttpServletResponse in the classes whose names r not concerned to us.
B'coz our interface can point(refer) to the object of those un-named classes.
This is same, how container call doGet() method of servlet while passing an object of type HttpServletRequest and HttpServletResponse.
e.g. HttpServletRequest req=new UnNamedClass();
=> Here, UnNamedClass has implement that HttpServletRequest interface.
2. Yr form tag in html has Action parameter along with Method parameter.
Where action will provide URL to identify the resource uniquely whereas at method u keep "HEAD".
<form name="f1" action="/helloWorld.html" method="HEAD">
What happed here is, HEAD method will just receive Header values not the whole html page.
"HEAD" method would be most useful in Web page Caching. Where u just check for Header,
Last-Modified
If it is the same as Cached page then Client browser will not make GET/POST request to srvr.This will atlast reduce the network traffic.
Hope, i m clear enough.
Best Regards, Dharmin
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Dharmin", please review our naming policy and update your display name. Thanks.

2. How can we send a header request to a servlet? I guess we can only send Get and Post requests through HTML? How about Head, Put and Delete?

No, they are all valid HTTP methods. HTTP/1.1 (RFC2616) supports OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE and CONNECT methods. HttpServlet provides corresponding Java methods for all of them except CONNECT, which is used in tunneling applications and not really relevant for servlets. See the HttpServlet javadoc for information about what the default implementations for each of these do.
- Peter
[ January 13, 2003: Message edited by: Peter den Haan ]
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! 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