| | |
get data from HTML form
![]() |
•
•
Join Date: Oct 2008
Posts: 89
Reputation:
Solved Threads: 0
I'm creating a SMTP client. I'm entering the data(to, from, subject, body) in a HTML form. How do I pass that data into the actual Java SMTP client so I can send it? I know how to hardcode the data into the client and send it that way but having trouble with letting the user enter the info. I've tried saving them as strings but had no luck.
•
•
Join Date: Oct 2008
Posts: 89
Reputation:
Solved Threads: 0
This is my java code that I have when I hard coded the information
Here is my code for the form
How do I pass those?
Java Syntax (Toggle Plain Text)
SMTPSender s = new SMTPSender(); s.setToAddress("email@host.edu"); s.setFromAddress("email@host.edu"); s.setSubject("subject"); s.setBody("this is the body"); s.sendMessage(); } } class SMTPSender{ String toAddress; public void setToAddress(String a){ toAddress = a; } String fromAddress; public void setFromAddress(String b){ fromAddress = b; } String subject; public void setSubject(String c){ subject = c; } String body; public void setBody(String d){ body = d; }
Java Syntax (Toggle Plain Text)
<h1>Mail Page</h1> Please type your mail stuff below: <form action=/mailer> To: <input name=toAddress ></input> </br> From: <input name=fromAddress ></input> </br> Subject: <input name=subject ></input> <br> Body: <input name=body ></input> <br> <input type=submit></input> </form>
•
•
Join Date: Apr 2006
Posts: 164
Reputation:
Solved Threads: 10
Easiest way to use jsp and make sure the server supports jsp. Then in form tag, <form action="mail.jsp" method= post>
Check http://www.jsptut.com/Forms.jsp for details.
Check http://www.jsptut.com/Forms.jsp for details.
A Perfect World
Use JSP's only for presenting data / view purposes only; use servlets for processing. Submit the above form to a servlet which would grab the mail related details, create a SMTPSender instance with the values obtained and do the required task.
Last edited by ~s.o.s~; Oct 23rd, 2008 at 3:07 pm.
I don't accept change; I don't deserve to live.
You have a few options. You can either host a web application in a servlet container like Tomcat, submit the form to the servlet which would then do the processing. Or you can either create a standalone GUI/Command Line client which accepts the input from the user and sends the mail.
I don't accept change; I don't deserve to live.
> Could I tokenize and parse the query string that is sent and set each tokenized part to
> toAddress, ect?
Sent where? Just having a HTML form doesn't help; you need to provide an action which will be executed once the form is submitted. Unless you have your own web application hosted somewhere, this isn't possible; there is nowhere for the data to be submitted.
> I'm not real familiar with jsp or servlets.
Now is a good time; head over to Sun's site for sample applications / tutorial. Either that or just create a simple console driven application.
> toAddress, ect?
Sent where? Just having a HTML form doesn't help; you need to provide an action which will be executed once the form is submitted. Unless you have your own web application hosted somewhere, this isn't possible; there is nowhere for the data to be submitted.
> I'm not real familiar with jsp or servlets.
Now is a good time; head over to Sun's site for sample applications / tutorial. Either that or just create a simple console driven application.
I don't accept change; I don't deserve to live.
![]() |
Similar Threads
- Parsing html form. (PHP)
- [urgent] HTML form => XML file (JSP)
- help needed in coloring html tables (JavaScript / DHTML / AJAX)
- Help with asp form will not display contact information (ASP)
- get posted form data in python (Python)
- Form not sending email (PHP)
- where to put .asp code into html code (ASP.NET)
- Populating a fields on a form base on a selected item from a droplist. (PHP)
Other Threads in the Java Forum
- Previous Thread: Random Number Generator Question
- Next Thread: Fetching data as Arabic from database??
| Thread Tools | Search this Thread |
2dgraphics account android api apple applet application array arrays automation banking bidirectional binary binarytree birt bluetooth chatprogramusingobjects class classes client code columns component database derby design eclipse encryption error errors expand fractal game givemetehcodez graphics gui guidancer homework html ide if_statement image inetaddress inheritance integer intellij j2me java javadesktopapplications javaprojects jlabel jme jni jpanel jtextfield julia linux list loop map method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source print problem program project property recursion reference ria scanner server set sms sort sourcelabs splash sql sqlite static stop string support swing testautomation threads tree ui unicode validation windows






