Howdy fellow ranchers, Is it possible to generate multiple requests from a single form which are passed to different servlets. (i.e. The user hits submit and two different servlets receive requests?) Any suggestions would be greatly appreciated.
Uhmm, why?? What functional advantage would you get if this was a possibility? As far as I understand, forms have one action. A form will submit one request. What you do with that request could have an infinite number of servlets.
Andrew, We have a JSP form. Once the form is complete it is written to a database however we also want to kick off an additional servlet which will send an e-mail to the person who entered the form. Forwarding the request through the database update servlet to the e-mail servlet is not an option.
Thanks Maha, I didn't even think of that but you are right. I can use an OnClick event. You and you example have been an inspiration to me. I used your website a great deal while I was chasing my SCJP. Now that I am a Java Developer I still find your advice very valuable.
regds maha anna [This message has been edited by maha anna (edited April 26, 2001).]
What Travis wants to do is so tricky because he is using the wrong tool for the job. A HTTP servlet (or JSP, or ASP) is a component which receives HTTP client requests and generates a HTTP responses to those clients. Anything that is not part of a chain which starts with the HTTP request and ends with the HTTP response should not be a servlet, JSP, ASP or whatever. The database update is best done in a JavaBean, class, custom tag, or EJB. If you want the update to happen asynchronously, i.e. move it out of the request->response chain, consider using JMS. Or in its most basic form, kick off a separate thread for the purpose. The e-mail facility does not want to be a servlet at all. Again, a JavaBean, class, tag, or (session) EJB could all be appropriate. And here too, if you want it to happen asynchronously, use JMS or a thread. A slightly more sophisticated alternative to kicking off a Thread for every e-mail would be to have an application-bound Java object which receives sendEmail() requests and has its own permanently running Thread in which it sends them off to the mail server. - Peter
[This message has been edited by Peter den Haan (edited April 27, 2001).]