html-jsp

Ads
 

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...........

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>

Ads









Related Tutorials/Questions & Answers:
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
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
Advertisements
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"> <
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
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
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
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
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
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
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
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
Tictactoe game-2 players- using jax webservices & jsp
and tell who is winner. Please help,atleast with the html/jsp coding and equivalent
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
How to retrieve array values from html form to jsp?
How to retrieve array values from html form to jsp?  Hi! I am... it into jsp. Means i just want to retrieve values from html form containing array... sample code for how to retrive array values from html to jsp.   hi friend
PlainText Result Example
raw content on a HTML or JSP file. To use the PlainText Result you need... location is the location of the HTML or JSP file. And charSet is type...="location">/jsp/helloPage.jsp</param> <param name="
Session In JSP
;   JSP: View Session The view consists of the Html page... to make Form with the help of html in jsp. By this example you can easily learn...Session In JSP      
struts2.2.1 include tag example.
of  html or jsp pages directly into current page or we can include output...; public String execute() { return SUCCESS;} } 3-include.jsp...;result>jsp/result.jsp</result> </action> <action name
Display image
Display image  How to Pass image from html to jsp and display that image using jsp   Here is an example that pass an image path from the html page to jsp page and display it. 1)page.html: <%@ page language="java
jsp:include action tag
or html page in the current jsp. Syntax: <jsp:include page = relative URL"... resource(i.e. html, jsp).  Example :In this example we have created a jsp file...-Type" content="text/html; charset=ISO-8859-1"> <title>JSP
JSF Interview Questions
. They can design look and feel of web application in html/jsp using custom tag...;  Bug fix release. No specification changes. No HTML renderkit... technology other than JSP,creating your own custom components and rendering
Struts 2 Tutorial and Examples
and following are pre-requisites for learning this framework. HTML JSP.... Create JSP file - This is the first step in creating login application...'s see how to configure browser request, Action and JSP page in our
Design, develop and test JSPs
JavaScript, HTML, or JSP tagging, including Java source code inside... to the index.jsp JSP: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01... JavaServer Pages (JSP) files You can create
Chapter 2. Design, build and test web components
Master.css, which is used for any HTML and JSP files included... the appropriate Sun Microsystems Servlet and JSP specification level.... Any new servlets and JSP files that you expect to create should adhere

Ads