reading data from a text box with the same name using servlets

reading data from a text box with the same name using servlets

Hello sir,
i want to get the values from four textboxes having the same name
like
a=<input type=text name="t1"><br>
b=<input type=text name="t1">
c=<input type=text name="t1">

using servlet i want to print all the values from each text box?

is it possible.this question i faced in an interview.


kindly reply to my question this is my first question?

so that i can think that this site is providing help to people


my mail id is [email protected]
View Answers

March 6, 2010 at 11:47 AM

Hi Friend,

Try the following code:

1)form.jsp:

<html>
<form method="post" action="../ServletExample">
<table>
<tr><td>TextBox1</td><td><input type="text" name="t1"></td></tr>
<tr><td>TextBox2</td><td><input type="text" name="t1"></td></tr>
<tr><td>TextBox3</td><td><input type="text" name="t1"></td></tr>
<tr><td>TextBox4</td><td><input type="text" name="t1"></td></tr>
<tr><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>

2)ServletExample.java:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ServletExample extends HttpServlet{
public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String values[]=req.getParameterValues("t1");
for(int i=0;i<values.length;i++){
out.println(values[i]+"<br>");
}
}
}

Thanks









Related Tutorials/Questions & Answers:
reading data from a text box with the same name using servlets - JSP-Servlet
reading data from a text box with the same name using servlets  Hello sir, i want to get the values from four textboxes having the same name like a= b= c= using servlet i want to print all the values from each text
How to get data from DB in to Text box by using Jsp & Ajax
How to get data from DB in to Text box by using Jsp & Ajax   I want to get the data from database in to text box in a jsp page by using Ajax. If I... with a and from that i need to select the required value and i should store
Advertisements
how to display data from mysql table in text box using jsp??
how to display data from mysql table in text box using jsp??  <p>hi, i have a written a code to display data from a mysql table into txtboxes...="row">Reference GPC</th> 113: <td><input type="text" name
Retrieve data from xml using servlets
Retrieve data from xml using servlets  Hi plz send me the code for retrieving the data from xml File using Servlets.   Hi, Do you want... File using ServletADS_TO_REPLACE_2 Thanks   Hi, Learn Get Data From
Populate a combo box using data from a database
Populate a combo box using data from a database  Hi Guys, In need... to the client using ajax, and then populate the combo box, I must'nt reload... combo box which will then load the next combo box values, now i know how
retrieve the data to text fields from database on clicking the value of combo box
retrieve the data to text fields from database on clicking the value of combo box   retrieve the data to text fields from database on clicking... getting data into textarea from database table by clicking on the button
Retrieving data from data base using jsp combo box
Retrieving data from data base using jsp combo box  Hi guys please... of the server it has to display the process name from database into the process name... combo box is there and another filed is version of the server(like 1.0,2.0) like
Acees data from database using combo box - JSP-Servlet
Acees data from database using combo box  please let me how i access the data from database when i select combo box combo2 having values Arts, Commerce, Science. this combo box will appear when first combo box class_name having
Reading text from image file - Java Beginners
Reading text from image file  How Read text from image file
create login page using data from text file
create login page using data from text file  I want to create login page using data store in textfile(data submit from regiter page to textfile) using jsp and servlet. Thanks
place data in text fields from database using jdbc
place data in text fields from database using jdbc  i want get the data from database and place the records in the respective textfields using jdbc and swing like eno,ename,loc from emp table
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
of worker name within d combo box and display that id into a text box. plz answer...how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my
how to get selected name from combo box
of worker name within d combo box and display that id into a text box. plz answer...how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my
how to get selected name from combo box
of worker name within d combo box and display that id into a text box. plz answer...how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my
fetching data using servlets - SQL
for fetching data from a ORACLE10g database using SERVLETS.   Hi Friend...fetching data using servlets  I have successfully made connection with the oracle10g database that i am using and also able to put in data using JSP
reading data using struts and jsp java
reading data using struts and jsp java  how can i read data entered... that after reading emp_id it can be read into struts action class for retrieving other employee related data
how to create a text box using awt
how to create a text box using awt  give an example how creat multi buttons & text boxes
how i conditional access the data from database using combo box. - JSP-Servlet
how i conditional access the data from database using combo box.   i have combox box named class when i select its value 11 or 12, another combo box... access the data from database when i select class 11 0r 12. Here is JSP file
create text box by clicking button and submittong text in text box using submit
create text box by clicking button and submittong text in text box using... is created. and i want to do that when i enter the text input in text box and when i... box in SOP). i also want the text box should generate in front of NEW button
reading data from excel file and plotting graph
reading data from excel file and plotting graph  I am doing a project... at the same time from one excel file using different columns..how can i do that? waiting... that reads an excel file using POI api and using the data of excel file
How to retrieve data from database by using combo box value in jsp? - JSP-Servlet
How to retrieve data from database by using combo box value in jsp?  .... Your code here.. CREATE TABLE "user" ( "name" character varying(100...---------------------------------- ---------------------------combobox.jsp------------------------------------ ------------ A:hover {text
Application reading data from JDBC database
Application reading data from JDBC database  I would like to develop an online registration system that captures details of potential candidates..." should read data from from a JDBC database named PrimeGame with TABLE PRIMEGAMETABLE
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  For example... ,the related employee name will be displayed in text field... i already stored combo box values from database. pl
Error in reading Excel data using jsp
Error in reading Excel data using jsp  ERROR while executing bellow code:java.io.IOException: Invalid header signature; read 576460838270094160... is not a proper xls file. It's a text file with a .xls extension s.t. Excel can quietly
populating text box using jsp code
populating text box using jsp code  Sir, How to populate related values in a text box after selecting value from drop down list using JSP and mysql. I tried using Ajax from your example. But for some browser it does not support
excel sheet reading and using that data - JSP-Servlet
excel sheet reading and using that data  i have to do a read a excel sheet file of a employee record and then i have to use a employee details to send mail to those employees how to do in jsp sir please help me sir.. Thanks
Reading from remote files using PHP,Ubuntu and Windows machine.
Reading from remote files using PHP,Ubuntu and Windows machine.  Hi... on a windows machine within the same network. After reading from it, the script.... I have a php question. Am working on a script that is suppose to read from
retriving data from sql server using jsp code and placing them in text fields of html code
retriving data from sql server using jsp code and placing them in text fields of html code  Hi, my question is how to retrieve data from sql..." and address "abbanna colony" in those text fields using a query "select * from
Insert value of dynamic generated text box in jsp using javascript
Insert value of dynamic generated text box in jsp using javascript  hello sir , i want to generate dynamic text box at run time and i did that using... that dynamically generated text box value into database at a time without
Line by Line reading from a file using Scanner Class
In this section, you will get to know about reading line by line a text file using java.util.Scanner class
Servlets errors in same page.
Servlets errors in same page.  How do I display errors list in the same page where a form field exists using servlets...........i.e. without using JSP? Please explain with a simple username password program
Retrieving Data from Database to fill Combo Box
Retrieving Data from Database to fill Combo Box  Sir, I have a JSP Page with a combo box and a label. I have a database that has two fields id and an image. Now I want to fill the combo box with image and on selecting
Reading xml file using dom parser in java with out using getelementby tag name
Reading xml file using dom parser in java with out using getelementby tag name  Hi, How to read the xml file using java with dom parser, but without using getelementbytag name, and also read the attribute values also. I had
how read data from doc file in same formate in jsp
how read data from doc file in same formate in jsp  how we can read and display data on jsp page, from doc file with the same formatting
take data from one table and insert same in another
take data from one table and insert same in another  I want to know when a new field update in table and the same data has to update in another table
retrieve value from db in text box + calendar implementation.
retrieve value from db in text box + calendar implementation.  I... there is already a text box..Now i want to get the value retrieved from database in that text field how can i do it... Please help...   Please visit
Importing data into sql plus from a text file...
Importing data into sql plus from a text file...  How to import a text file into oracle 10g enterprise edition directly to create tables and data
Importing data into sql plus from a text file...
Importing data into sql plus from a text file...  How to import a text file into oracle 10g enterprise edition directly to create tables and data
JDialog to create a customized dialog box for entering text data
JDialog to create a customized dialog box for entering text data   ... dialog box for entering text data. The dialog can be split into panes, left pane can contain an image file and the right pane will contain multiple text fields
Reading a text file in java
Reading a text file in java  What is the code for Reading a text file... in java.io.* package for reading and writing to a file in Java. To learn more about reading text file in Java see the tutorial Read File in Java. Thanks
how to prevent no from unroundin off on clicking text box again in JSP and Jquery
how to prevent no from unroundin off on clicking text box again in JSP and Jquery  I am rounding off numbers entered in a text box in jsp but when I reclick that text box ,It shows the same no (unrounded no) again , Though
Use of Select Box to show the data from database
Use of Select Box to show the data from database       Example program using Select Box to show retrieved data... page to show the data fetched from the database. We are using Servlet to get data
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp   data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp with script of data base plz help me
How to Validate dynamically created text box in HTML using Javascript
How to Validate dynamically created text box in HTML using Javascript ...'); newdiv.innerHTML = "<input type=\"text\" name=\"txt"+num +"\" />" ; newdiv1.innerHTML="<input type=\"text\" name=\"txt1"+num1
How to retrieve data using combo box value in jsp? - JSP-Servlet
How to retrieve data using combo box value in jsp?  Hi freind, I already post this question. I need urgent help from u. pl response me.... All actions in the same page.......  Hi Friend, Please visit
using getText() to retrieve text from an array of text fields with loop.
using getText() to retrieve text from an array of text fields with loop.  ... presses button. Now I want to get the text from all the textfields using array...;i++) { value[i]=text[i].getText(); } //here value is an array. //text
JPA read data from database example
from database using JPA. Create a "JPARead.java" file and follows the following steps to reading data from database. Create "JPARead" class... JPA read data from database example   
Reading the data from property file from java stand alone application in linux
Reading the data from property file from java stand alone application in linux  Please send me the example of reading the data from a property file from java stand alone application in linux. I don't know how to give path

Ads