>>> Robert Zhang <[EMAIL PROTECTED]> 20-Jun-00 10:10:21 PM
>>>

>I want to simulate form data posting from one servlet
>to another.

>For example,
>  response.setHeader("Location", "/destinationservlet");
>  response.setContentType("text/html");
>  response.setHeader("Method", "POST");      // is this correct?

Can't be done I'm affraid.

There are 2 possibilities for hacking it:

1. output a page to the browser with the POST (as a form) which
points to your target servlet - then have JS on the page immediatly
action the form.

2. overload the request going to a RequestDispatcher

  RequestDispatcher
rd=getServletContext().getRequestDispatcher("/destinationservlet");
  HttpServletRequest fooledrequest=new HttpServletRequest()
     {
          // implementation of all methods...

           public String getMethod()
            {
               return "POST";
             }

             public String getRequestURI()
              {
                   return request.getRequestURI();
               }
       };

Neither method is very good but I would suggest the former is a
better because it's not a simulation.


Nic Ferrier

___________________________________________________________________________
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

Reply via email to