File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Two questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Two questions" Watch "Two questions" New topic
Author

Two questions

Dinesh Kumar
Ranch Hand

Joined: Jul 03, 2002
Posts: 54
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.
Dharmin Desai
Ranch Hand

Joined: Feb 28, 2002
Posts: 81
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


SCJP2 (93%),SCWCD(88%)<br />-------------------------------<br />Never under estimate yr self, just represent yr profile in proper manner.
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
"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 ]
 
wood burning stoves
 
subject: Two questions