Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


deepti mishra
html-jsp
1 Answer(s)      2 years and 8 months ago
Posted in : Java Beginners


If i want to get dynamic value in html textbox or in jsp,then how can I get the value,how the value will be transfered from servlet page to the html textbox.Thanx in advance.....Kindly help me...........


Advertisement
View Answers

March 5, 2012 at 4:58 PM


1)Servlet.java:

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

public class Servlet extends HttpServlet{
    protected void doPost(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException{

ArrayList list=new ArrayList();
try{
     Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from employee");
           while(rs.next()){
               list.add(rs.getString("name"));
               list.add(rs.getString("address"));
               list.add(rs.getString("contactNo"));
               list.add(rs.getString("email"));
}
req.setAttribute("data", list);
        RequestDispatcher rd = req.getRequestDispatcher("/jsp/data.jsp");
        rd.forward(req, res);
}
catch(Exception e){
}
    }
}

2)data.jsp:

<%@page language="java" import="java.util.*" %>
<html>
<body> 
<table border="1" width="303">
<tr>
<td width="119"><b>Name</b></td>
<td width="168"><b>Address</b></td>
<td width="119"><b>Contact no</b></td>
<td width="168"><b>Email</b></td>
</tr>
<% Iterator itr;%>
<% List data=(List)request.getAttribute("data");
for(itr=data.iterator(); itr.hasNext(); ){
%>
<tr>
<td width="119"><input type="text" value="<%=itr.next()%>"></td>
<td width="168"><input type="text" value="<%=itr.next()%>"></td>
<td width="168"><input type="text" value="<%=itr.next()%>"></td>
<td width="168"><input type="text" value="<%=itr.next()%>"></td>
</tr>
<%}%>
</table>
</body>
</html>


Related Tutorials/Questions & Answers:
html-jsp - getparameter() - JSP-Servlet
html-jsp - getparameter()  Hi! friedns, This is my front end and I want to retrieve username and password in two different jsp pages. I used getParameter() with two form action as shown below. But I am not getting
html-jsp
html-jsp  If i want to get dynamic value in html textbox or in jsp,then how can I get the value,how the value will be transfered from servlet page to the html textbox.Thanx in advance.....Kindly help me
Advertisements
Html+jsp+database is enough to do the small operation
Html+jsp+database is enough to do the small operation  Hai , If u want to do simple insetion and data retrival operation throw jsp ?.you need not to bother about whole code.just u consentration on html,ajax,jsp,any db.here i
HTML - JSP-Servlet
HTML   To process a value in jsp project I have to set the text box as non editable. what is the attribute and value to be submitted... code. Visit for more information. http://www.roseindia.net/jsp
javascript-html - JSP-Servlet
javascript-html  i want to dynamically create textfield with option button as another/remove when user presses in jsp page which will be in table.for example table contains one row with 2 columns,one textfield,second dropdown
javascript-html - JSP-Servlet
javascript-html  i want to dynamically create textfield with option button as another/remove when user presses in jsp page which will be in table.for example table contains one row with 2 columns,one textfield,second dropdown
html - JSP-Servlet
explain in detain and send me code. login application in jsp...; } Login Application in JSP...; ------------------------------------------ Visit for more information. http://www.roseindia.net/jsp/ Thanks Amardeep
how to add the calendar to the dynamic rows in html or jsp page - JSP-Servlet
how to add the calendar to the dynamic rows in html or jsp page   Hi Sir, i have 3 columns in my jsp page date of payment,amount recieved,no and i have 2 button in my jsp page ADD and delete button. when i click on add
how to insert data in database using html+jsp
how to insert data in database using html+jsp  anyone know what is wrong with my code? print("<% /* Create string... method="post" action="http://localhost:8080/examples/jsp/insert.jsp"> <
i use HTML in jsp - JSP-Servlet
i use HTML in jsp  i want to make a list box of select state and corresponding to the selected state all the names of cities will be displayed...://www.roseinda.net/jsp
Data fetching from JSP or HTML - JSP-Servlet
Data fetching from JSP or HTML  Hi Deepak, Can u pls help me as i have a problem with jsp/html frameset. my question is how can i fetch the data from frameset which is in html format.pls help me. Thanks
Link from html to jsp - Development process
html link button , control should go to jsp page wat i mentioned in view... Friend, To give link from html page to jsp, you have to run the jsp page.After that specify the full path of jsp in html page with href tag. Use
call a wep page using html - JSP-Interview Questions
call a wep page using html  Dear, Please I want to call a jsp page using a HTML Button called View. When the user click on it, a new JSP web page will opened. Can you help me please. Thanks in advance  Hi Friend
eSpell
, JavaProperties, C, C++, XML, HTML, JSP, and PHP. With support for Aspell
RequestDispatcher in java
resource to another web resource (such as a Servlet, HTML, JSP) on the server... either a servlet, or a JSP page, or an HTML file in the response. The servlet 1... the request between server resources,(Servlet to Servlet, HTM and JSP
Setting and Getting Data in jsp through the Session
Setting and Getting Data in jsp through the Session          In this example you will learn how to make Form with the help of html in jsp. By this example
retrive values - JSP-Servlet
retrive values  how to get multiple values from html to jsp
Source code of a website in HL and JSP.
Source code of a website in HL and JSP.  I want the source code of a website of 10 pages with database connectivity. Source code should be in HTML and JSP. Thanks
jar file with html
jar file with html  I have a jar file. On double click it shows an applet page. Please tell me how to connect that applet into html or jsp page
question
to an html page after checking the database for different users.for eg:your user name or password is incorrect.reply me with code, without using bean.using servlet,html,jsp and simple java script.i don't know ajax
ecilpse
ecilpse  just now i have entered into IT development field facing many difficulties being a fresher just tel me how to work with eclipse an connection establishment in jdo and html jsp etc.... getting many confusion while writing
javascript Code - JSP-Servlet
javascript Code  how to count controls in form and find no of contriols in html or jsp page.for example one table is there with 10 rows,each row consists of 3 fields as 2 text box and one drop down box
javascript date picker - Date Calendar
javascript date picker  how to insert a date picker user control in a html/jsp using javascript??? please help, it's urgent.  Hi Friend.../javascript-calendar.shtml http://www.roseindia.net/jsp/emp-event.shtml Thanks
simple - JDBC
simple  can we have update,delete,save button in one html or jsp form performing respective operation if yes, give me code respectively.  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp
multipications table
multipications table  i need to do a Form (decide if this should be html or jsp file). Form contains an HTML form with two fields:a text input..... Table (decide if this is HTML or JSP) Table shows the multipications table up
Tomcat
the project in tomcat where we can store the html and Jsp ad Java, XML files... way or not.send me the one simple application code in java,servlets,html,jsp... apps-my project(beside this one jsp file) Inside the my project WEB-INF
jps
the programmers to embed Java code into html (.jsp) page. For more information...what is the jsp  what is the jsp   ava Server Pages is a technology from Sun that enables the Java programmers to generate HTML, XML
Tictactoe game-2 players- using jax webservices & jsp
and tell who is winner. Please help,atleast with the html/jsp coding and equivalent
html - IDE Questions
html  how to run html page in eclipse  You can't direct run a html/jsp page in eclipse. if it is pure static page then you can through the design tab. other wise type the addres of your page in eclipse browser
JSP - JSP-Servlet
JSP  how to get the input in a jsp page which was entered by the user in another jsp page?? 'request.getParameter' that is used for html to jsp... the problem : 1.Create a JSP page "test.jsp" and submit the form
Advertisements
 

 

 

DMCA.com