Elaine Chong wrote:
>
> Hello,
> I have a servlet that processes forms (POST requests) and I would like to
> mimic filling out the form with my own java program. Is there a way for me
> to create an HttpServletRequest? If this isn't possible, would anyone be
> able to suggest an alternative strategy?
If you just want to make a request to the servlet like a web browser
would, you can use URLConnection.
If you want to do testing at the HTTP request level, see HttpUnit at
<http://httpunit.sourceforge.net/>.
Cactus, at <http://jakarta.apache.org/>, is a tool for servlet unit
testing which lets you mimic requests. The test cases run inside the
servlet container. It's designed to let you test methods other than
doGet and doPost which need servlet API objects. (The idea is that if
you're testing doGet and doPost, you should just use HttpUnit or
equivalent.)
In the servlet 2.3 world, you could use a request filter and the
HttpServletRequestWrapper class to mimic a request with a given set of
parameters.
Gennis
___________________________________________________________________________
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