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:
Advertisements
Retrieve data from xml using servletsRetrieve
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 databasePopulate 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
Retrieving data from data base using jsp combo boxRetrieving
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-ServletAcees
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
create login page using data from text filecreate 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
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 javareading 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 graphreading 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
Application reading data from JDBC databaseApplication
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
Error in reading Excel data using jspError 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 codepopulating
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-Servletexcel 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
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 BoxRetrieving
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 a text file in javaReading 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
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