aspose file tools*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

how to connect the HTML form with my servlet

voilet annexton
Greenhorn

Joined: May 13, 2007
Posts: 8
hi

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.io.*;
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

<servlet>
<servlet-name>thankyou</servlet-name>
<servlet-class>Thanks</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>thankyou</servlet-name>
<url-pattern>/Thanks.do</url-pattern>
</servlet-mapping>

i wrote ACTION Thanks.do
METHOD post

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

please help me by giving suggestions

thnks
voilet
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

Please do not post the same question more than once.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to connect the HTML form with my servlet