MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

Java Servlet Programing Laungage

Java Servlet Projects

Servlet Project 3

Java Servlet :Manipulating multiple value parameters
Previous Home Next

The following example illustrates the use of the getParameterValues method to get all favourite music selected by the user.The code for this servlet is as follows:

index.html

<html>
 <head>
  <title>Check box Demo</title>
 </head>
 <body>
  <form method = "post" action = "music">
  <p>Which type of music you like it ? </p>
  <input type = "checkbox" name ="favouritemusic" 
value = "Rock">
   Rock<br>
  <input type = "checkbox" name ="favouritemusic" 
value = "Jazz">Jazz<br>
  <input type = "checkbox" name ="favouritemusic" 
value = "hiphop">hiphop.<br>
  <input type = "checkbox" name ="favouritemusic" 
value = "pop">pop<br>
  <input type = "checkbox" name ="favouritemusic" 
value = "heavy rock">heavy rock<br>
  <input type ="submit" name= "submit">
  </form>
 </body>
</html>

 

web.xml

<web-app>
 <servlet>
  <servlet-name>H1</servlet-name>
  <servlet-class>GetParamValues</servlet-class>
 </servlet>
 <servlet-mapping>
  <servlet-name>H1</servlet-name>
  <url-pattern>music</url-pattern>
 </servlet-mapping>
</web-app>

GetParamValues.java

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class GetParamValues extends HttpServlet{
  protected void doPost(HttpServletRequest request, 
    HttpServletResponse response)throws ServletException,IOException 
{
  String[] values=request.getParameterValues("favouritemusic");
  response.setContentType("text/html");
  PrintWriter pw = response.getWriter();
  if(values!=null)
  {
   int length=values.length;
   for(int i=0;i<length;i++)
   pw.println("<br>Favourite Music : " + values[i]);
  }
 }
 }
Previous Home Next