Hi Saumont
Thanks for your reply. Yes, I need a program that reads my printer port and
sends the data to a servlet which would put it on my web-site.
Thanks again
Ken
>From: Saumont Pierre-Yves <[EMAIL PROTECTED]>
>Reply-To: "A mailing list for discussion about Sun Microsystem's Java
> Servlet API Technology." <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: sending email from html form? how
>Date: Mon, 26 Mar 2001 10:21:35 +0200
>
>I am not sure to understand what you mean. Do you mean a program reading
>the
>printer port on the client and sending the data to a servlet that put the
>data on a web site ? Or a program reading the printer port on the server
>(?)
>and send the data to the client ?
>
>Pierre-Yves
>
>-----Message d'origine-----
>De : A mailing list for discussion about Sun Microsystem's Java Servlet
>API Technology. [mailto:[EMAIL PROTECTED]]De la part de ken
>dias
>Envoy� : samedi 24 mars 2001 01:40
>� : [EMAIL PROTECTED]
>Objet : Re: sending email from html form? how
>
>
>Hi Saumont
>
>I am trying to develop a servlet that will read a data line of my printer
>port and post the data read on my web-site. Do you have or can you suggest
>any code snippets that can do this?
>
>Thanks
>
>Ken
>
>
> >From: Saumont Pierre-Yves <[EMAIL PROTECTED]>
> >Reply-To: "A mailing list for discussion about Sun Microsystem's Java
> > Servlet API Technology." <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: Re: sending email from html form? how
> >Date: Thu, 22 Mar 2001 14:19:11 +0100
> >
> >Hi,
> >
> >her is a servlet skeleton to send mail from a servlet by connecting to a
> >mail server (no JavaMail).
> >
> >Again, this example is taken from my book "Servlet et Java Server Pages -
> >Le
> >guide du d�veloppeur" (published in french);
> >
> >As is, it will probably not compile because I have taken off all the
>stuff
> >concerning getting teh data from a database trough JDBC.
> >
> >Note that parameter are to be red from a property file, so that the
>servlet
> >is somewhat portable.
> >
> >I have introduce a few words of comments to translate the methods name in
> >english.
> >
> >I hope it helps !
> >
> >Pierre-Yves
> >
> >public class MailServlet extends HttpServlet {
> >
> > String propFileName = "default.prop";
> >
> > public void service (HttpServletRequest requete,
> > HttpServletResponse reponse) throws
> >ServletException, IOException{
> >
> > String path =
> >getServletConfig().getServletContext().getRealPath("/");
> > reponse.setContentType("text/html");
> > PrintWriter pw = reponse.getWriter();
> > Properties properties = new Properties();
> > try {
> > FileInputStream propFile = new
> >FileInputStream(path + propFileName);
> > properties.load(propFile);
> > }
> > catch (IOException ioe) {
> > System.out.println(ioe);
> > return;
> > }
> > .
> > .
> > .
> >
> > String expe = properties.getProperty("expe"); // expe =
> >sender
> > String dest = properties.getProperty("dest"); // dest is
> >the adress wher
> >you are sending mail
> > String sujet = properties.getProperty("mailSubject");
> > StringBuffer buffer = new StringBuffer();
> > StringBuffer message = new StringBuffer();
> >
> > message.append("Hi,\n\n");
> > message.append("This is the text of the message...\n");
> > message.append("....\n");
> > message.append(".....\n");
> > message.append("Best regards\n\n");
> >
> > String serveur = properties.getProperty("mailServer");
> > Socket socket = new Socket(serveur, 25);
> >
> > PrintWriter mailWriter
> > = new
> >PrintWriter(socket.getOutputStream(), true);
> > BufferedReader mailReader
> > = new BufferedReader(new
> >InputStreamReader(
> >
>socket.getInputStream()));
> >
> > connecter(serveur, mailWriter, mailReader, buffer); //
> >buffer wil contains
> >mailserver response (usefull for tracking problems)
> > envoyerCommande("MAIL FROM:", expe, mailWriter,
> >mailReader, buffer);
> > envoyerCommande("RCPT TO:", expe, mailWriter,
>mailReader,
> >buffer);
> > envoyerCommande("DATA", "", mailWriter, mailReader,
> >buffer);
> > envoyerDonn�es(dest, sujet, message.toString(),
> >mailWriter, mailReader,
> >buffer);
> > fermer(socket, mailWriter, mailReader, buffer);
> >
> > //pw.println(buffer.toString()); // This is for tracking
> >problems with teh
> >server
> > }
> > }
> >
> > }
> > private void connecter( // connecter = connect
> > String serveur,
> > PrintWriter mailWriter,
> > BufferedReader mailReader,
> > StringBuffer buffer)
> > throws IOException
> > {
> > buffer.append("<p>" + mailReader.readLine());
> > buffer.append("HELO " + serveur + "\r\n");
> > mailWriter.print("HELO " + serveur + "\r\n");
> > mailWriter.flush();
> > buffer.append("<br>" + mailReader.readLine());
> > }
> >
> > private void envoyerCommande( // envoyerCommande = send command
> > String commande,
> > String param�tre,
> > PrintWriter mailWriter,
> > BufferedReader mailReader,
> > StringBuffer buffer)
> > throws IOException
> > {
> > buffer.append("<br>" + commande + param�tre + "\n");
> > if (!param�tre.equals(""))
> > {
> > param�tre = "<" + param�tre + ">";
> > }
> > mailWriter.print(commande + param�tre + "\r\n");
> > mailWriter.flush();
> > buffer.append("<br>" + mailReader.readLine());
> > }
> >
> > private void envoyerDonn�es( // envoyerDonn�es = send data
> > String dest,
> > String sujet,
> > String message,
> > PrintWriter mailWriter,
> > BufferedReader mailReader,
> > StringBuffer buffer)
> > {
> > buffer.append("to: " + dest + "\r\n");
> > mailWriter.print("to: " + dest + "\r\n");
> > buffer.append("subject: " + sujet + "\r\n");
> > mailWriter.print("subject: " + sujet + "\r\n");
> > buffer.append(message + "\r\n");
> > mailWriter.print(message + "\r\n");
> > }
> >
> > private void fermer( // fermer = shut
> > Socket socket,
> > PrintWriter mailWriter,
> > BufferedReader mailReader,
> > StringBuffer buffer)
> > throws IOException
> > {
> > mailWriter.print("\r\n.\r\n");
> > mailWriter.flush();
> > buffer.append("<br>" + mailReader.readLine());
> > buffer.append("<br>" + "QUIT" + "\n");
> > mailWriter.print("QUIT" + "\r\n");
> > mailWriter.flush();
> > buffer.append("<br>" + mailReader.readLine());
> > socket.close();
> > }
> >}
> >
> >-----Message d'origine-----
> >De : A mailing list for discussion about Sun Microsystem's Java Servlet
> >API Technology. [mailto:[EMAIL PROTECTED]]De la part de roy
> >woods
> >Envoy� : jeudi 22 mars 2001 13:48
> >� : [EMAIL PROTECTED]
> >Objet : sending email from html form? how
> >
> >
> >Hi all
> >
> >How can I send an email from html form? I know I
> >should have the JavaMail package first and should know
> >the name of the SMTP. what else do I need to have?
> >Could someone be kind enough to post a simple code
> >that sends the an email to the email especified in the
> >form with the content in the form's textarea?
> >
> >thanks in advance
> >
> >Roy--
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Get email at your own domain with Yahoo! Mail.
> >http://personal.mail.yahoo.com/
> >
> >___________________________________________________________________________
> >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
>
>_________________________________________________________________________
>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>___________________________________________________________________________
>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
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
___________________________________________________________________________
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