Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the following Exercise. Comment on this servlet example. In your own words write a description of the code in all of the multiple line

Complete the following Exercise.

Comment on this servlet example. In your own words write a description of the code in all of the multiple line comment sections. To successfully complete this assignment, you will need to research the Internet for more information on servlets.

For example, in the following you will need to define FormInputsServlet, extends, and HttpServlet.

/* * FormInputsServlet: * extends: * HttpServlet: */

FormInputsServlet - Servlet Example

package week3a; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.annotation.*; import java.io.*; import java.util.*; /* * FormInputsServlet: * extends: * HttpServlet: */ public class FormInputsServlet extends HttpServlet{  /* * @Override: * doGet: * HttpServletRequest: * HttpServletResponse: */ @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{  /* * PrintWriter: */ PrintWriter out = response.getWriter(); printHeader(out); out.println("

GET

"); printForm(out); printFooter(out); } /* * doPost: */ @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ PrintWriter out = response.getWriter(); printHeader(out); out.println("

Output Form Data

"); out.println("
"); out.println(request.getParameter("hiddenInput")); out.println(" "); out.println(request.getParameter("select")); out.println(" "); out.println(request.getParameter("textarea")); out.println(" "); out.println(request.getParameter("radioButton")); out.println(" "); if(request.getParameter("checkBox_1[]") == null){ out.println("No checkboxes were selected - 8."); } else{ String[] checkBoxSelected = request.getParameterValues("checkBox_1[]"); out.println("
    "); for(String value : checkBoxSelected){ out.println("
  • " + value + "
  • "); } out.println("
"); } out.println(" "); out.println(request.getParameter("password_1")); out.println(" "); out.println("
"); printForm(out); printFooter(out); } public void printHeader(PrintWriter out){ out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println("Form Post & Get"); out.println(""); out.println(""); out.println(""); out.println(""); out.println("
"); } public void printFooter(PrintWriter out){ out.println("
"); out.println(""); out.println(""); } public void printForm(PrintWriter out){ out.println("
"); out.println("

"); out.println(""); out.println("

"); out.println("

"); out.println(""); out.println(""); out.println("

"); out.println("

"); out.println(""); out.println(""); out.println("

"); out.println("

"); out.println(""); out.println("
"); out.println(""); out.println("
"); out.println(""); out.println("
"); out.println(""); out.println("

"); out.println("

"); out.println(""); out.println(""); out.println(""); out.println(""); out.println("

"); out.println("

"); out.println(""); out.println("

"); out.println("

"); out.println(""); out.println("

"); out.println("

"); out.println(""); out.println("

"); out.println("
"); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Bioinformatics Databases And Systems

Authors: Stanley I. Letovsky

1st Edition

1475784058, 978-1475784053

More Books

Students also viewed these Databases questions

Question

Is SHRD compatible with individual career aspirations

Answered: 1 week ago