You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Rob Wilson <ne...@gmail.com> on 2007/10/17 19:12:59 UTC

Ant - invoke a servlet?

Hi All,

I plan to have a servlet that is invoked via JSP to upload some files to a
dynamic website, I would like to enable my Ant build to make use of this
servlet too.  Is this possible? Could someone please shed some light on how
this can be achieved?

Perhaps I can't do it as a servlet and need to consider a web-service or RMI
instead? Any advice would be appreciated.

Thank you,
Rob.

Re: Fwd: Ant - invoke a servlet?

Posted by Rob Wilson <ne...@gmail.com>.
Hi Steve,

Thank you for your reply, I found the HTTP library you mention, inside the
'sandbox' SVN repositories (for future reference).

SVN Url is http://svn.apache.org/repos/asf/ant/sandbox/antlibs/http/trunk

Out of curiousity, is there a location with pre-built jars that I could have
used?  I was not sure how to initiate the build because the top-level build
shows an error (default target dist does not exist in this project), so I
changed it from "distrib" to "distribution" which successfully built (after
having to change from the JRE to JDK).

Now that it's built, it looks like from the http-antlib-html that the
HttpPost will enable me to upload a file, or parameters, but not both.  So,
if I wanted to send the same data as one of my forms that contained say a
username, password, id and image file, how can I do this in one operation?

If I have to split them up, that would be ok, but I would still need to pass
some sort of identifier for the file being uploaded? The file is intended to
be a sealed JAR file.  I can consider hacking it such that the JAR is
bundled inside a temporary jar that contains some metadata, but isn't there
another (better?!) way of doing this?

(PS Whats do you think the reason is for the restriction on upload v
parameters?)

Many thanks,
Rob.

Re: Fwd: Ant - invoke a servlet?

Posted by Steve Loughran <st...@apache.org>.
Rob Wilson wrote:
> Hi All,
> 
> I plan to have a servlet that is invoked via JSP to upload some files to a
> dynamic website, I would like to enable my Ant build to make use of this
> servlet too.  Is this possible? Could someone please shed some light on how
> this can be achieved?
> 

The <get>task does a get.

For more complex http operations, there is an httptasks antlib in Ant's 
subversion repository, which gives you <post>.
I dont know about file uploading.

> Perhaps I can't do it as a servlet and need to consider a web-service or RMI
> instead? Any advice would be appreciated.

Being proficient in both, I would strongly encourage you to reach the 
limits of http first

-- 
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

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


Re: Fwd: Ant - invoke a servlet?

Posted by Rob Seegel <Ro...@comcast.net>.
You might also consider writing a custom task to get what you're looking 
for. It wouldn't take much code at all to create a thin wrapper around 
httpclient to upload files.

The following article might be helpful:

 
http://www.theserverside.com/tt/articles/article.tss?l=HttpClient_FileUpload

Rob



Rob Wilson wrote:
> Hi All,
> 
> I plan to have a servlet that is invoked via JSP to upload some files to a
> dynamic website, I would like to enable my Ant build to make use of this
> servlet too.  Is this possible? Could someone please shed some light on how
> this can be achieved?
> 
> Perhaps I can't do it as a servlet and need to consider a web-service or RMI
> instead? Any advice would be appreciated.
> 
> Thank you,
> Rob.
> 


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


Fwd: Ant - invoke a servlet?

Posted by Rob Wilson <ne...@gmail.com>.
Hi All,

I plan to have a servlet that is invoked via JSP to upload some files to a
dynamic website, I would like to enable my Ant build to make use of this
servlet too.  Is this possible? Could someone please shed some light on how
this can be achieved?

Perhaps I can't do it as a servlet and need to consider a web-service or RMI
instead? Any advice would be appreciated.

Thank you,
Rob.