See messages below.
Bye,
Jiger
>From: Sandeep Tikoo <[EMAIL PROTECTED]>
>Reply-To: "A mailing list for discussion about Sun Microsystem's Java
> Servlet API Technology." <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: RequestDispatcher Again.
>Date: Mon, 21 Aug 2000 14:13:21 -0700
>
>Hi all,
>
>In my servlet I have to forward my request to a static
>html page (URL being say,
>http://localhost:8080/error.html), which I do with a
>requestDispatcher.forward(). I have noticed that when
>my servlet overides the doGet method, rather than
>doPost,and is subsquently called with a doGet request
>it works fine. However if the servlet overides the
>doPost rather than the doGet method and is invoked
>from a for with Method=post attribute I get the HTTP
>405 error something like this:
>*************************************************
>Error 405
>An error has occured while processing
>request:http://localhost:8080/error.html
>Message:HTTP method POST is not supported by this URL
>*************************************************
>at the point where the servlet tries to forward the
>request to the HTML page.
>
>Why does this happen, even though the servlet API for
>the RequestDispatcher.forward() clearly says in its
>first line:
>
>"Forwards a request from a servlet to another resource
>(servlet, JSP file, or HTML file) on the server."
>
When you are forwarding to another servlet Are you specifying any method??
The answer is NO. So the default Method GET is taken & so if you are
overriding the doGet method it runs & when you override the doPost only it
does not.
>I have been through the archives and have noticed that
>other people have also faced similar problems.
>
>Is this a bug or am I missing something here?
>
>Another question regarding
>requestDispatcher.forward().
>
>The API says:
>"The request and response parameters must be the same
>objects as were passed to the calling servlet's
>service method"
>
>If that is the case, then wouldnt it have been better
>if the signature of the forward method was
>
>public void forward()
>
>with the request and the response objects being passed
>implicitly by the servlet engine to the invoked
>resource, rather than it being as it is rightnow:
>
>public void forward(ServletRequest request,
> ServletResponse response)
>
>Am I again missing something?
Well when a Servlet is created by the Servlet Engine it initializes it &
then when a request comes in it passes it the requisite information like
request & response objects & forgets about it. Now within the Servlet
whatever you do the forward method or the Servlet Engine has no way to
recover the Request & Response Objects per servlet since they are created
per invocation. So you have to pass it.
>
>-thanks
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Mail � Free email you can access from anywhere!
>http://mail.yahoo.com/
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html