Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

submitting a form and sending an email (using JSP)

Avatar of shamskm
shamskm asked on
10 Comments1 Solution335 ViewsLast Modified:
Hi there,

I am completley new to JSP (my background is in PHP).

I am trying to write a JSP script that will take the values of a html <form> and append them to an email.

For example, here are two sample <form>'s

<form name="test_form_1" id="test_form_1" method="post" action="email_form.jsp">
Full Name: <input type="text" name="full_name" id="full_name"  />
Address: <input type="text" name="address" id="address"  />
Telephone: <input type="text" name="telephone" id="telephone"  />

<form name="test_form_2" id="test_form_2" method="post" action="email_form.jsp">
Appointment Day: <input type="text" name="appointment_day" id="appointment_day"  />
Appointment Date: <input type="text" name="appointment_date" id="appointment_date"  />
Appointment Time: <input type="text" name="appointment_time" id="appointment_time"  />

I would like the email_form.jsp script to handle form elements that are not predetermined.  i.e. a script that will iterate through any submitted form elements, apend them to an email, and then send the email.

I would expect the resulting email for the above two processed forms to resemble something like this:

full_name: value
address: value


appointment_day: value
appointment_date: value
appointment_time: value

Here is my email_form.jsp script so far

Obviously lots are missing, how do i get all the varibales from a submitted form and make string out of it?

I'd also like to pass the "from" email address as a hidden value in the form.


String to = "";

String subject = "Feedback received from form name: ";

String from = "";

      confmessage = "<strong>Thank you, email sent</strong> ";
catch (Exception e)
      confmessage = "<strong>Unfortunatly your message could not be sent.</strong>";  


Thanks for looking! Your help is much appreciated.

Avatar of Peter Kwan
Peter KwanFlag of Hong Kong imageAnalyst Programmer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answers