aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes question 994784367093 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 "question 994784367093" Watch "question 994784367093" New topic
Author

question 994784367093

Timber Lee
Ranch Hand

Joined: Oct 14, 2002
Posts: 157
Question ID :994784367093
Which statement regarding the following method of class HttpServlet is correct?
doOptions(HttpServletRequest, HttpServletResponse);
1.it is call when container receives HTTP PUT request,
2,it is call when container receives HTTP POST request,
3,it is call when container receives HTTP FORM request,
4,it is call when container receives HTTP HEAD request,


SCJP<br />SCWCD<br />SCEA
AJAY RANA
Ranch Hand

Joined: May 30, 2002
Posts: 75
Dear Lee,
The answer would be "None of these" as this method would be called on OPTIONS request.
This is from API :
" Called by the server (via the service method) to allow a servlet to handle a OPTIONS request. The OPTIONS request determines which HTTP methods the server supports and returns an appropriate header".
Regards ,
Ajay Rana
kavitha yalamanchili
Greenhorn

Joined: Oct 10, 2002
Posts: 25
Ajay,
How does doOptions get called in the first place?
If I have method as OPTIONS in my JSP.. it is always the doGet that is being called..
Iam a little confused here.. why is doGet being called?
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
kavitay,
a construct like
<select>
<option>kavitay option
<option>axel option
</select>
is not meant here.
Its about method of http request.
URL requests allways generate a HTTP-GET.
With <form> tag you can send different requests to the browser.
like:
<form action="/cgi-bin/auswert.pl" method="post" target="Daten">
or
<form action="/cgi-bin/auswert.pl" method="options" target="Daten">
kavitha yalamanchili
Greenhorn

Joined: Oct 10, 2002
Posts: 25
This is the line of code that I had in my jsp
<form method="OPTIONS" action="../servlet/HelloWorldServlet">
and in HelloWorldServlet I had doGet, doPost and doOptions methods.
now when I load my JSP I see the message that I have in doGet.
so when the method="OPTIONS" is given in the JSP, it is doGet that is being called. Can someone explain why doGet is called?
I think what happens is may be doOptions is called when ever service method is called to check if the method that is being requested is allowed or not. Iam not sure..
Timber Lee
Ranch Hand

Joined: Oct 14, 2002
Posts: 157
Hi,kavitha, do you try PUT and HEAD ? is doGet() called?
kavitha yalamanchili
Greenhorn

Joined: Oct 10, 2002
Posts: 25
yes, doGet is called if the methods are the ones u mentioned
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: question 994784367093