• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

having problem related to form submission using servlets

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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
 
voilet annexton
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
I didn't say it. I'm just telling you what this tiny ad said.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic