"Lambert, Stephen : CO IR" wrote:
>
> How does one pass values from a doGet(select) and then email those values
> from a doPost method.
>
> I can successfully split the methods into separate servlets and they
> individually run fine.
> But, I'm not sure how to combine the to methods. i.e. store 200 values and
> then reference all 200 values into the message body of an email.
>
> If someone could point to an example, I would be greatly appreciative!

Do you mean you want to call doPost from doGet? And pass 200 values? A
servlet class can have both doPost and doGet methods. The method doPost
can be overloaded just like any other Java method:

doGet(HttpServletRequest req, HttpServletResponse res) {
  Vector v = new Vector();
  //put 200 values into come collection, perhaps a vector...
  //but could be array, or Hashtable, or List, or Set or ...
  //and call doPost
  doPost(req, res, v);
}

//overloaded doPost
doPost(HttpServletRequest req, HttpServletResponse res, Vector vec) {
  //send email using info from vec
}

Why do you specifically need to call the method doPost? You can name the
second method anything you want. Also, this other method probably
doesn't need access to any specific functionality from req or res, and
even if it did, you could put that information into the collection along
with all the other information. so now you have

sendEmail(Vector vec) {
  //send email using info from vec
}

Finally, does this method really need to be a part of the servlet.
There's a school of thought that says servlet should just be
request/response, and other behavior belongs in other classes. So,
consider creating a class to handle email, and calling the methods of
that class from doGet.

doGet(.....) {
  //fill vector vec with parms from req
  MyMail m = new MyMail();
  m.setParms(vec);
  m.mail();
}

K Mukhar

___________________________________________________________________________
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

Reply via email to