jsp and servlet

jsp and servlet

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,and values will be of string type or integer type or date type.........Thanx in advance.....Kindly help me...........

View Answers

March 15, 2012 at 12:13 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 doGet(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException{
        form.EmpBean p = new form.EmpBean();
        List 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"));

}
}
catch(Exception e){}
        req.setAttribute("data", list);
        RequestDispatcher rd = req.getRequestDispatcher("/jsp/data.jsp");
        rd.forward(req, res);
    }
}

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:
servlet and jsp
servlet and jsp  how to connect an jsp and an servlet without connecting to database
Servlet - JSP-Servlet
Servlet and Java Code  Example and source code in Servlet and JSP
Advertisements
Servlet - JSP - JSP-Servlet
Servlet - JSP  i used arraylist in servlet as shown ArrayList total = new ArrayList (); ... total.add(k[i]); session.setAttribute("efg",total); when I code this like in my jsp <%ArrayList<Integer> data= new
Servlet - JSP - JSP-Servlet
Servlet - JSP  Here is my complete code. all my code is running with out any error. the for loop in servlet is running as many times as my checkboxes... Servlet Code: ---------------------- package com.servlet; import
jsp servlet
jsp servlet  i dont know how to write a code to Create a JSP with one text field to enter the URL and a submit button.On clicking the submit button, send the request to a servlet .Once the servlet receives the request, it need
jsp servlet
jsp servlet  i dont know how to write a code to Create a JSP with one text field to enter the URL and a submit button.On clicking the submit button, send the request to a servlet .Once the servlet receives the request, it need
JSP-Servlet
JSP-Servlet  Hi have created a JSP page and I need to print it when the user clicks on the print button. I have put a print button on the JSP page. Can somebody plz help me out with the Servlet page coding
jsp and servlet
the data and delete the data,using jsp and servlet...jsp and servlet  I want to create a login form,which have many fields,and have a connectivity with thwe oracle database,and login form will have
jsp and servlet
jsp and servlet  hello friends just want to create a jsp page... login from login page and if we submit it shud be validated in a servlet using... links: http://www.roseindia.net/jsp/loginbean.shtml http://www.roseindia.net
jsp servlet
code to Create a JSP with one text field to enter the URL and a submit button  i dont know how to write a code to Create a JSP with one text field... the request to a servlet .Once the servlet receives the request, it need to create
jsp servlet
how to write a code to Create a JSP with one text field to enter the URL  i dont know how to write a code to Create a JSP with one text field... to a servlet .Once the servlet receives the request, it need to create a thread
servlet and jsp
servlet and jsp  how can i get a form question from a database... with servlets and jspīs   Have a look at the following links: http://www.roseindia.net/jsp/paging.shtml http://www.roseindia.net/jsp/navigation
How to call servlet in JSP?
How to call servlet in JSP?  How to call servlet in JSP
jsp servlet
jsp servlet  dispay hindi in jsp
Java Servlet - JSP-Servlet
Java Servlet   Hello Sir Could you help me in understanding directory Structure for servlet page in eclipse (IDE). I save my Sevlet in WEB-INF but it is not displaying, it is displaying code of servlet. Process used
jsp and servlet
jsp and servlet  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... javax.servlet.*; import javax.servlet.http.*; public class Servlet extends
calling servlet from jsp
calling servlet from jsp  how to call a servlet from jsp
EL in jsp - JSP-Servlet
. The default mode for JSP pages delivered using a Servlet 2.3 or earlier descriptor... for JSP pages delivered with a Servlet 2.4 descriptor is to evaluate EL...EL in jsp  hai, I tried to test EL operators in my jsp i
Servlet Question - JSP-Servlet
Servlet Question  I want to call one servlet when the browser window is closed by User
Servlet Question - JSP-Servlet
Servlet Question  I want to call one servlet when the browser window is closed by User
SERVLET AND JSP
SERVLET AND JSP  If i want tio create a login form using SUBMIT,ADD...;For more information visit the following links: http://www.roseindia.net/jsp/user...://www.roseindia.net/answers/viewqa/JSP-Servlet/16413-using-insert-and-delete-in-a-single
SERVLET AND JSP
SERVLET AND JSP  If i want tio create a login form using SUBMIT,ADD...;For more information visit the following links: http://www.roseindia.net/jsp/user...://www.roseindia.net/answers/viewqa/JSP-Servlet/16413-using-insert-and-delete-in-a-single
jsp program - JSP-Servlet
jsp program  1.write a servlet program that finds out the given... an application in jsp to redirect the request to any other page.  Hi Friend...,please go through the following link: http://www.roseindia.net/jsp/jsp
Servlet,Jsp
Servlet,Jsp   This is my requirement?I have a login page and register page?If I give the url as http://localhost:8080/Project/Login.jsp ,it should go to login page?.then from login page on click of register button I can register
JSP-Servlet
JSP-Servlet  Hi , I have a table and a checkbox box in that. If i select a particular checkbox, then the particular row details has to be fetched and should be given to two buttons..i/e. when i click on a checkbox, two buttons
jsp servlet
jsp servlet  i have to create one application in which at one page login id will be entered and after entering it will go to second page where first name,last name, date of birth has to be filled and save buttom has to be pressed
Jsp servlet
Jsp servlet  Hai , i want add image details to database how ,please help   Here is a jsp code that allow the user to select the file and and upload it, then save it to database with some details like file path
java - JSP-Servlet
java  why is required to write both jsp and servlet in a application of java
Servlets vs JSP - JSP-Servlet
and servlet act as a controller. 2)JSP pages contain a mixture of HTML, Java scripts, JSP elements, and JSP directives while servlet is totally uses java code. 3... and servlet is used for bussiness logic 5)Servlets are faster than jsp. 6
JSP AND SERVLET
JSP AND SERVLET  I want to create a login form with user name and password field,if the user is new then s/he can click on the new user hyperlink and new page will be display,and data will be updated to the database successfully
coding in jsp & servlet
coding in jsp & servlet  plz... provide me coding of "online examination system" in jsp & servlet
Example questions of JSP & Servlet
Example questions of JSP & Servlet  Give me some JSP & Servlet Question and their answers
jsp - JSP-Servlet
jsp  how i connect oracle database (using type-1 driver) from jsp page ?  Hi friend, Read for more information. http://www.roseindia.net/jsp/sumTable.shtml Thanks
java - JSP-Servlet
java  what is the difference between jsp and servlet?   Hi firend, Main difference between Jsp and Servlet Jsp is better for view web pages, while servlet is good for request processing. Jsp has also all
servlet - JSP-Servlet
is my servlet program output,what is the solution...' ,you ve to set the path to servlet.jar or servlet-api.jar which is under common
JSP - JSP-Servlet
JSP  How to store selected combo value in a String variable.. in JSP without AJAX. pls.... help me....  Hi friend, Using Jquery to store selected combo value in jsp : http://www.roseindia.net/ajax/jquery
JSP - JSP-Servlet
JSP  This is the error which i got in my JSP page. "The value for the useBean class attribute SQLBean.DbBean is invalid." please help me...://www.roseindia.net/jsp/java-beans.shtml Thanks
meterchart in jsp - JSP-Servlet
meterchart in jsp  Hi, How to use Meter chart in jsp. If you have dat code pls share it... Regards..., Britto.M
Programmig in JSP - JSP-Servlet
Programmig in JSP  Write a JSP Program, which displays a web page... it goes to a JSP page which display current date and time and by clicking on link for schedule of your practical sessions of say,PQRSmodule another JSP page
jsp servlet hosting
jsp servlet hosting  Hi, What is jsp servlet hosting? Thanks   In case of jsp servlet hosting, hosting companies are providing hosting environment where client can host Java based web application on the server
jsp - JSP-Servlet
that session ??????  Hi friend, Disabling Session in JSP By default... to visit.... http://www.roseindia.net/jsp/disablingsession.shtml Thanks
JSP and servlets - JSP-Servlet
JSP and servlets  Hi sir, This is vanisree in my project i need to add the start time of examination and end time of examinaion and if the time between end and start are greater than one hour then i need to close that session
JSP - JSP-Servlet
JSP  Gd afternoon sir, Morning i send a query that how to call the questions in the jsp page.The send answer provides that all questions are displayed in same page but i need the questions have to be come in different pages one
JSP - JSP-Servlet
://www.roseindia.net/jsp/online-quiz-application-jsp.shtml Thanks   
login authentication in jsp and servlet
to make login authentication in jsp and servlet? Thanks   Hi, I to make login authentication in jsp and servlet you have to write code for database... it with complete code: Login Authentication using Bean and Servlet In JSP JSP
Calculator - JSP-Servlet
Calculator  Dear Deepak Sir, Calculator program is avilable in Jsp/Servlet plz send me. Thanks & Regards, VijayaBabu.M  Hi vijay calculator program in jsp function checkValue(){ var msg
Project - JSP-Servlet
Project  Can you send me the whole project on jsp or servlet so that i can refer it to create my own : the topic is Advertisement Management System Atleast tell me how many modules does it include
java servlets - JSP-Servlet
java servlets  how to get the parameter value of input type file using java servlets  Hi, You can use request.getParameter(). In Jsp, --- --- IN servlet, String fileName=request.getParameter('fl'); If you
jsp/servlet login program
jsp/servlet login program  <%@ page language="Java" import...;/TITLE></HEAD> <BODY> <jsp:useBean id="db" scope="request" class="logbean.LoginBean" > <jsp:setProperty name="db" property="userName" value
Populating child dropdownlists in JSP/Servlet
Populating child dropdownlists in JSP/Servlet  Populating child dropdownlists in JSP/Servlet

Ads