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

Ads
 

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

Ads









Related Tutorials/Questions & Answers:
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
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
Advertisements
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 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 to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB:student; @table:stu_info; Combobox values:(class1,class2,class3); textbox1
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  Hi Friends... in combo box from database.. by using select*from studentinformation; But when i... related value.... I am using only this page.. not get value from another page
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
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

Ads