Answered step by step
Verified Expert Solution
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(""); printForm(out); printFooter(out); } /* * doPost: */ @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ PrintWriter out = response.getWriter(); printHeader(out); out.println("GET
"); out.println("Output Form Data
"); 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("
"); printForm(out); printFooter(out); } public void printHeader(PrintWriter out){ 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(""); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started