feedback Form : Form « Servlets « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. EJB3
14. Email
15. Event
16. File Input Output
17. Game
18. Generics
19. GWT
20. Hibernate
21. I18N
22. J2EE
23. J2ME
24. JDK 6
25. JNDI LDAP
26. JPA
27. JSP
28. JSTL
29. Language Basics
30. Network Protocol
31. PDF RTF
32. Reflection
33. Regular Expressions
34. Scripting
35. Security
36. Servlets
37. Spring
38. Swing Components
39. Swing JFC
40. SWT JFace Eclipse
41. Threads
42. Tiny Application
43. Velocity
44. Web Services SOA
45. XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » Servlets » FormScreenshots 
feedback Form

       
<HTML><HEAD><TITLE> feedback Form </TITLE></HEAD>
<BODY><H1> Feedback Form </H1>
<HR>
<BR>
<FORM NAME="ParameterPost" ACTION="/servlets-examples/PrintFormParams" METHOD="POST">
<TABLE BGCOLOR="BLANCHEDALMOND" ALIGN="CENTER" BORDER="0">
    <TR>
    <TD ALIGN="CENTER"><B>Name:</B></TD> 
    <TD ALIGN="CENTER"> <INPUT TYPE="TEXT" SIZE="25" NAME="Person"></TD>
    </TR>
   
    <TR>
    <TD ALIGN="CENTER"><B>Email:</B></TD> 
    <TD ALIGN="CENTER"> <INPUT TYPE="TEXT" SIZE="25" MAXLENGTH="40" NAME="emailaddress"></TD>
    </TR>
   
   
    <TR>
    <TD ALIGN="CENTER"><B>How did you find this site?</B></TD> 
    <TD ALIGN="CENTER"
        <SELECT NAME="from" SIZE="1">
        <OPTION VALUE = "Website" SELECTED>Another Website</OPTION>
        <OPTION VALUE = "search engine">A search engine</OPTION>
        <OPTION VALUE = "friend">A friend told you</OPTION>
        <OPTION VALUE = "email">From an email</OPTION>
        <OPTION VALUE = "unlisted">Another way not listed here</OPTION>
        </SELECT>
    </TD>    
    </TR>
   
    <TR>
    <TD ALIGN="CENTER"><B>How would you rate my website:</B></TD> 
    <TD ALIGN="CENTER"
    <INPUT TYPE="radio" NAME = "rating" VALUE = "Excellent"> Excellent 
    <INPUT TYPE="radio" NAME = "rating" VALUE = "Good"> Good 
    <INPUT TYPE="radio" NAME = "rating" VALUE = "Average" CHECKED> Average 
    <INPUT TYPE="radio" NAME = "rating" VALUE = "Poor"> Poor 
    <INPUT TYPE="radio" NAME = "rating" VALUE = "Overhaul"> Needs an Overhaul
    </TD>
    </TR>
   
    <TR>
    <TD ALIGN="CENTER"><B>Comments or Suggestions:</B></TD> 
    <TD ALIGN="CENTER"
    <TEXTAREA ROWS="6" COLS="40" WRAP="PHYSICAL" Name="suggestions">
             Enter any comments or suggestions you have here.</TEXTAREA>
    </TD>
    </TR>
    
    <TR>
    <TD ALIGN="CENTER"><B>Do you think this form looks nice?</B></TD> 
    <TD ALIGN="CENTER"
    <INPUT TYPE="CHECKBOX" NAME="formrating" VALUE="yes">
    </TD>
    </TR>
   
    <TR>
    
    <TD ALIGN="LEFT">
    
    <INPUT TYPE="SUBMIT" VALUE="Send Comments" ALIGN="MIDDLE">  &nbsp; &nbsp;
    <INPUT TYPE="RESET" VALUE="Clear Form" ALIGN="MIDDLE"
    
    </TD>
    </TR>
   
</FORM>
</BODY>
</html>

<!-- web.xml -->
    <servlet>
        <servlet-name>PrintFormParams</servlet-name>
        <servlet-class>PrintFormParams</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>PrintFormParams</servlet-name>
        <url-pattern>/PrintFormParams</url-pattern>
    </servlet-mapping>
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class PrintFormParams extends HttpServlet {

  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    PrintParams(request, response);

  }

  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    PrintParams(request, response);
  }

  public void PrintParams(HttpServletRequest request,
      HttpServletResponse responsethrows IOException {

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

    String htmlHeader = "<HTML><HEAD><TITLE> Printed Form Parameters </TITLE></HEAD><BODY>";
    String htmlFooter = "</BODY></HTML>";

    out.println(htmlHeader);
    out.println("<TABLE ALIGN=CENTER BORDER=1>");
    out.println("<tr><th> Input Name </th><th> Value </th>");

    Enumeration enum = request.getParameterNames();

    while (enum.hasMoreElements()) {
      String inputName = (Stringenum.nextElement();
      String value = request.getParameter(inputName);

      if (value.length() != 0) {
        out.println("<tr><td align=center>" + inputName + "</td>");
        out.println("<td align=center>" + value + "</td></tr>");
      else {
        out.println("<tr><td align=center>" + inputName + "</td>");
        out.println("<td align=center><i>Null</i></td></tr>");
      }

    }
    out.println("</TABLE><BR>");
    out.println(htmlFooter);
  }
}



           
       
Related examples in the same category
1. Servlets Form TextField
2. HTML Forms with Servlets
3. React to user form input
4. Basic Form processor
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.