You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jose Euclides da Silva Junior - DATAPREVRJ <Jo...@rj.previdenciasocial.gov.br> on 2003/05/28 00:26:45 UTC

RES: servlet question

try doGet() instead of doPost().
good luck.

-----Mensagem original-----
De: Paul Hsu [mailto:hsu.paul@verizon.net]
Enviada em: terça-feira, 27 de maio de 2003 19:27
Para: tomcat-user@jakarta.apache.org
Assunto: servlet question


Hi,

I try to forward a HTTP request from my servlet. I am using the following
code.

RequestDispatcher rd =
                    getServletContext().getRequestDispatcher(direct);
rd.forward(request, response);

I have no problem with code, but I have one issue is how can I change the
request method from "POST" to "GET" before I forward the original request.

I would appreciate any help

Paul 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: servlet question

Posted by Bill Barker <wb...@wilshire.com>.
You need to wrap the request with a wrapper that overrides the getMethod()
method.  Something like:
 class GetWrapper extends HttpServletRequestWrapper {
      public GetWrapper(HttpServletRequest request) {
         super(request);
     }
     public String getMethod() {
         return "GET";
     }
 }

 GetWrapper wrapper = new GetWrapper(request);
 RequestDispatcher rd =
                     getServletContext().getRequestDispatcher(direct);
 rd.forward(wrapper, response);


"Paul Hsu" <hs...@verizon.net> wrote in message
news:005e01c324a0$ff1fb060$6400a8c0@smartequip.net...
> Thank you for the help. I think you may misunderstand my question. My
> question is how can I forward the request to my next URL and change the
> method to 'GET' if the orignal request is using 'POST'.
> For example:
>
> test1.html call servlet1 by using "POST" method, but servlet1 need to
> forward to servlet2 by using "GET". How can I switch from "POST" to "GET"
in
> servlet1.
>
> thanks
>
> ----- Original Message -----
> From: "Jose Euclides da Silva Junior - DATAPREVRJ"
> <Jo...@rj.previdenciasocial.gov.br>
> To: "'Tomcat Users List'" <to...@jakarta.apache.org>
> Sent: Tuesday, May 27, 2003 3:26 PM
> Subject: RES: servlet question
>
>
> try doGet() instead of doPost().
> good luck.
>
> -----Mensagem original-----
> De: Paul Hsu [mailto:hsu.paul@verizon.net]
> Enviada em: ter�a-feira, 27 de maio de 2003 19:27
> Para: tomcat-user@jakarta.apache.org
> Assunto: servlet question
>
>
> Hi,
>
> I try to forward a HTTP request from my servlet. I am using the following
> code.
>
> RequestDispatcher rd =
>                     getServletContext().getRequestDispatcher(direct);
> rd.forward(request, response);
>
> I have no problem with code, but I have one issue is how can I change the
> request method from "POST" to "GET" before I forward the original request.
>
> I would appreciate any help
>
> Paul
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: servlet question

Posted by Paul Hsu <hs...@verizon.net>.
Thank you for the help. I think you may misunderstand my question. My
question is how can I forward the request to my next URL and change the
method to 'GET' if the orignal request is using 'POST'.
For example:

test1.html call servlet1 by using "POST" method, but servlet1 need to
forward to servlet2 by using "GET". How can I switch from "POST" to "GET" in
servlet1.

thanks

----- Original Message -----
From: "Jose Euclides da Silva Junior - DATAPREVRJ"
<Jo...@rj.previdenciasocial.gov.br>
To: "'Tomcat Users List'" <to...@jakarta.apache.org>
Sent: Tuesday, May 27, 2003 3:26 PM
Subject: RES: servlet question


try doGet() instead of doPost().
good luck.

-----Mensagem original-----
De: Paul Hsu [mailto:hsu.paul@verizon.net]
Enviada em: terça-feira, 27 de maio de 2003 19:27
Para: tomcat-user@jakarta.apache.org
Assunto: servlet question


Hi,

I try to forward a HTTP request from my servlet. I am using the following
code.

RequestDispatcher rd =
                    getServletContext().getRequestDispatcher(direct);
rd.forward(request, response);

I have no problem with code, but I have one issue is how can I change the
request method from "POST" to "GET" before I forward the original request.

I would appreciate any help

Paul

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org