File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
    Bookmark Topic Watch Topic
  • New Topic

how to connect the HTML form with my servlet

 
voilet annexton
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not post the same question more than once.
 
I agree. Here's the link: http://aspose.com/file-tools
    Bookmark Topic Watch Topic
  • New Topic