On Mon, 21 Feb 2000, Wayne Elliott wrote:
> I am looking at the UploadTest servlet from Jason Hunter's Java Servlet
> Programming. This works fine using a html form like this ...
>
> <FORM ACTION="/wpe/servlet/UploadTest" ENCTYPE="multipart/form-data"
> METHOD=post>
> What is your name? <INPUT TYPE=TEXT NAME=submitter> <BR>
> Which file do you want to upload? <INPUT TYPE=FILE NAME=file> <BR>
> <INPUT TYPE=SUBMIT>
> </FORM>
>
> However, I would like to call this servlet from within a Java program.
>
> I tried to use Oreilly's HttpMessage class to call the servlet...
>
> urlStr = "http://localhost:8080/wpe/servlet/UploadTest";
> URL url = new URL(urlStr);
> HttpMessage msg = new HttpMessage(url);
> Properties props = new Properties();
> props.put("submitter", "wayne");
> props.put("file", "c:\\kuz7.jpg");
> InputStream in = msg.sendPostMessage(props);
>
> At this point I get an exception regarding it not being
> multipart/form-data.
>
> I tried modifying HttpMessage (where the Netscape bug fix code is)
> to get the content type right. Then I go a "missing boundary" error.
>
> I then tried setting the content type in HttpMessage thus
>
> con.setRequestProperty(
> "Content-Type", "multipart/form-data;
> boundary=---------------------------2799030872219");
>
> At this point the java app just hangs there, ruminating on its purpose.
>
> The multipart aspect of the called servlet seems to be the problem.
> If I could just understand what information the form is sending, perhaps
> I could emulate it better from within Java.
>
> I feel I am loitering in hack city, drifting further and further away
> from the simple truth I need to proceed. Can someone explain what needs
> doing to get this app to work.
>
> WPE
>
Try using the get request to send the info to your servlet, its a lot
simpler, or try using the RequestDispatcher.
> ___________________________________________________________________________
> 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
>
___________________________________________________________________________
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