It's not a secret anymore!*
The moose likes Servlets and the fly likes how to connect the HTML form with my servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic

how to connect the HTML form with my servlet

voilet annexton

Joined: May 13, 2007
Posts: 8

im new in this forum

i want help regarding connecting the form to the servlet i made
im making a website using dreamweaver
in the contact us page i'ave made a form.
This form is supposed to submitt the data about clients to the company.
i'ave made a servlet,compiled,deployed and tested it

my servlet looks like this

import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;

public class Thanks extends HttpServlet {
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws IOException {

response.setContentType ( "text/html" );
PrintWriter out = response.getWriter();

String f_name = request.getParameter ( "fname" );// gets first name
String l_name = request.getParameter ( "lname" );// gets last name
String e_mail = request.getParameter ( "email" );// gets email
String phone = request.getParameter ( "phn" );// gets phone no.
String address = request.getParameter ( "add" );// gets address
String cty = request.getParameter ( "city" );// gets city
String sta = request.getParameter ( "state" );// gets state
String pn_code = request.getParameter ( "pincode" );// gets pin code
String com = request.getParameter ( "comment" );// gets comments

out.println (" <html> " +
"<body> " +
"<h1 style = text-align : center>" +
" Vardhman Udhyog </h1>" +
"<br>First Name " + f_name +
"<br>Last Name " + l_name +
"<br>email address " + e_mail +
"<br>Phone number " + phone +
"<br>Address " + address +
"<br>City Name " + cty +
"<br>State " + sta +
"<br>Pincode " + pn_code +
"<br>comment " + com );

and the deployment discriptor looks like this



i wrote ACTION

but still im confused whether its write or wrong
and yes my form is not working

please help me by giving suggestions

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60741

Please do not post the same question more than once.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
jQuery in Action, 2nd edition
subject: how to connect the HTML form with my servlet
Similar Threads
having problem related to form submission using servlets
Servlet help
A page not found error
having problem in connecting HTML form to servlet