This discussion is archived
1 Reply Latest reply: Aug 12, 2013 10:11 PM by S.K.Saha RSS

Get multiple textbox value in CheckBox values attribute in jsp and fetch the checkbox value in servlet

S.K.Saha Newbie
Currently Being Moderated



i have written this in jsp




<%@page import=""%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">



<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

<script type="text/javascript">

function getvalue(){

  var elems = document.getElementsByTagName('input');

  var values = [];

  for(var i=0; i< elems.length; i++){

  if (elems[i].type == "text"){




  for(var i=0; i< values.length; i++){








<form action="checkbox">



<td>First Name:<input type="text" name="first"  id="text1"/></td>

<td>Second Name:<input type="text" name="second"  id="text2"/></td>

<td>check both<input type="checkbox" id="chk" name="allValue" value="<%=request.getAttribute("res")%>" onclick="getvalue()"/>



<tr><td><input type="submit" value="OK" ></td>








And Servlet Code



package com.test;



import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;





public class TestServlet extends HttpServlet {



  protected void service(HttpServletRequest req,HttpServletResponse res)


  String[] str=req.getParameterValues("allValue");

  for(int i=0;i<str.length;i++)










here i am getting null value in servlet even though i have set the all textbox values in request in javascript function as i have written in above code



please suggest me if any solution is there




  • Correct Answers - 10 points
  • Helpful Answers - 5 points