Thanks Phil,
I implemented something similar to your first suggestion and used javascript
form.submit() to submit the form.
This seems to work well - with two slight issues .....
(1) It works fine for the first form, but if I want to fill in multiple
forms in sequence (such as doing a registration or soemthing) then it
becomes a problem - because the first form needs to keep control throught
the whole process.
i.e if test.jsp is the first form ... it needs to
--- get form1.htm
--- prefills and submits form1.htm
--- parses the response ...
--- get form2.htm
--- prefills and submits form2.htm
--- parses the response ...
--- get form3.htm
--- etc ...
the problem is that as soon as the form is posted the result is returned to
the browser and test.jsp no longer has control. Is there anyway to avoid
this?
(2) In testing I have actually been reading and posting forms on a local
server. I just tried to auto post some forms to external (internet) servers
and I'm having problems ... the request for the page timesout and throws a
"NoRouteToHostException" which I think is because it cant find it way
through the firewall. How can I setup the URL connection to go through the
firewall?
----- Original Message -----
From: Phil Campbell <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; Paul Allton <[EMAIL PROTECTED]>
Sent: Wednesday, March 22, 2000 5:08 PM
Subject: Re: Automatically Submitting Forms
> Paul:
>
> Something like this may work; we have a similar logic working elsewhere
(on
> code we control).
>
> As I understand your question, two implementations are possible. Both
assume
> knowledge of external html Form source code.
>
> FIRST IMPLEMENTATION: Automate form default values for user input.
>
> We use code that allows us to fill-in forms that we control. The logic
> seems applicable to any form code, following something like this pseudo
> code:
>
> 1) JSP/Servlet opens second page url; reads source into local String
> var, say strVar.
> 2) Look for input vars (find strVar.indexOf( somevarname )
> 3) Find positions of related html <input> tag (index of nearest < and
>
> tag delimiters)
> 4) replace entire <input ...> tag with a <input name=... [value] >
> string for somevarname
> 5) send strVar as response to client
>
> SECOND IMPLEMENTATION: Automate second Form POST from first Form data
(does
> not require user input).
>
> (This would be like having form ONE capture information to be posted
so
> an external server, say as an automatic submission to Yahoo.com, for
> example.)
>
> Simply create hidden html form with the new data and post it to the
> external form server... (I think Real Gagnon
> (http://tactika.com/realhome/realhome.html) discusses Post to a url. If
not,
> someone else here has posted information on how to do it -- check the
> archives.)
>
> Your choice of languages for either of these implementations; Java is my
> preferred choice -- much easier to do in Java than in C and I think
> performance is comparable. ( Zhu Jiang suggested JavaScript; don't know if
> his idea is plausible and can find no reason to use client side technology
> in this application. Besides, this is a server side technology group ;-)
>
> If you need help or an example, let me know.
>
> Good luck.
>
> Phil
>
> -----Original Message-----
> From: wee kb <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> Date: Wednesday, March 22, 2000 2:49 AM
> Subject: Re: Automatically Submitting Forms
>
>
> >Broken link!
> >
> >At 09:58 AM 3/22/00 +0200, Zhu Jiang wrote:
> >>You can just use Java Script to do that work. check out Java Script
object
> >>road map you can find the answer.
> >>
> >>here is a link:
> >>
>
>>http://developer.netscape.com/viewsource/goodman_ssjsrmap/goodman_ssjsrmap
> .h
> >>tml
> >>
> >>
> >>zhu jiang
> >>
> >>-----Original Message-----
> >>From: EXT Paul Allton [mailto:[EMAIL PROTECTED]]
> >>Sent: 19. March 2000 11:03 PM
> >>To: [EMAIL PROTECTED]
> >>Subject: Automatically Submitting Forms
> >>
> >>
> >>I have a form and I want to collect some info on it and based on that
info
> I
> >>then want to got to a second page and prefill the form elements with
that
> >>data. Then I want to submit that form.
> >>
> >>The problems:
> >>1) this all needs to happen automatically
> >>2) the second page is an external link and the source code therefore
> cannot
> >>be altered.
> >>
> >>Using JSP or a servlet whats the best way to prefill the form and post
it?
> >>Can it be done?
> >>
> >>If it cant be down using Java, can it be done with Javascript, PERL,
cgi -
> >>anything?
> >>
>
>>==========================================================================
> =
> >>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> >JSP-INTEREST".
> >>Some relevant FAQs on JSP/Servlets can be found at:
> >>
> >> http://java.sun.com/products/jsp/faq.html
> >> http://www.esperanto.org.nz/jsp/jspfaq.html
> >> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> >> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >>
> >
>
>===========================================================================
> >To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> >Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
>
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets