File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes having problem related to form submission using servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "having problem related to form submission using servlets" Watch "having problem related to form submission using servlets" New topic
Author

having problem related to form submission using servlets

voilet annexton
Greenhorn

Joined: May 13, 2007
Posts: 8
hi!!!

i'm new in this forum.
i'm assigned a work to create a website, including a contact us page which contains a form.
i'ave made up a form but now i'm having a problem to submit the same.
making a setrvlet for submitting the form is easy but the real problem is that
where should i store my servlet?
how will it work when a user submits the form?
where will the form data be stored?
when the website is uploaded where the form data will be stored?

i'm so confused.please give me some suggestions.

rgds
voilet
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61201
    
  66

"violet",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
voilet annexton
Greenhorn

Joined: May 13, 2007
Posts: 8
hi

i'ave made the servlet,compiled.deployed ,and tested it
but now my real problem is that how should i connect it with my contact form.i wrote

ACTION Thanks.do
METHOD post

Thanks is my servlet and it looks like

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

public class Thanks extends HttpServlet {
public void doGet(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 );
}
}

my deployment discriptor looks like

<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>

please solve my problem.
Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
Your form can be look like this


The action attribute of form tag is linked to Thanks.do and you have mapped that url-pattern in your deployment descriptor(web.xml)
voilet annexton
Greenhorn

Joined: May 13, 2007
Posts: 8
now my form is working but i dont know what should be done so that when the user submits it,i can have it.where will the form going to be stored online?

if you have any suggestions please help me.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41823
    
  63
Please don't post the same question to multiple forums. Although the question really belongs in this forum, let's continue the discussion in this duplicate thread, where you have an answer already.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: having problem related to form submission using servlets