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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Ngeaw Kam Wah
Data Redundancy
0 Answer(s)      4 years and 9 months ago
Posted in : JSP-Interview Questions


Sorry for disturbing you again but there's redundancy of the selected data on this jsp u gif me. The selected data will appear twice at the drop down box. I've tried to fix it but still unable to do so. Is there anything can be done?


<%@ page language="java" import="java.util.*"%>
<%@ page import="java.sql.*,java.io.*,javax.servlet.*,javax.servlet.http.*,java.lang.String
"%>
<html>
<head>
<script type="text/javascript">
function change()
{
var answer = document.getElementById('selc').value;
window.location.replace("test.jsp?name="+answer);
}
</script>
</head>
<%
String connectionURL = "jdbc:mysql://localhost:3306/register";;
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test";, "root", "root");
String ans=request.getParameter("name");
response.setContentType("text/html");
String address = "";
String name = "";
try {
String sql = "select * from data where name = '"+ans+"'";
Statement s = connection.createStatement();
s.executeQuery (sql);
ResultSet rs = s.getResultSet();
while (rs.next ()){
address = rs.getString("address");
name=rs.getString("name");
}
rs.close ();
s.close ();
}
catch(Exception e){
System.out.println("Exception is ;"+e);
}
System.out.println(address);

%>

<body>
<h1>Use of Select Box in JSP</h1>
<table border="1" width="41%" height="53" cellspacing="0" cellpadding="3"
bgcolor="#000080" bordercolorlight="#FFFFFF">
<tr>
<td width="100%" height="18" colspan="2"><b>
<font color="#FF00FF">Select items from select box</font></b></td>
</tr>
<tr>
<td width="17%" height="23">
<select onChange="change();" id="selc" >
<%
Statement st=connection.createStatement();
ResultSet rs=st.executeQuery("select name from data");
while(rs.next()){
%>
<option value="<%=rs.getString("name")%>"><%=rs.getString("name")%></option>
<%
if(name.equals(rs.getString("name"))){
%>
<option value="<%=rs.getString("name")%>"selected=selected><%=rs.getString("name")%>></option>
<%
}

}%>
</select>
</td>
<td width="83%" height="23"><input type="text" id="textvalue" value="<%= address %>" />
</td>
</tr>
</table>
</body>
</html>


Advertisement
View Answers

Related Tutorials/Questions & Answers:
Data Redundancy - JSP-Interview Questions
Data Redundancy  Sorry for disturbing you again but there's redundancy of the selected data on this jsp u gif me. The selected data will appear twice at the drop down box. I've tried to fix it but still unable to do so
CRC(cyclic redundancy check) - UML
CRC(cyclic redundancy check)  write a program that accepts a data sequence , generates a fcs (using a known divisor) and then ultimately check whether the recieved data is in error
Advertisements
data
data  Handling data
data
data  data Handling AOP
data
data  Handling data in AOP
data
data handling examples in AOP Model  data handling examples in AOP Model
What is VRRP?
; VRRP the acronyms of  Virtual Router Redundancy Protocol is ...; the data  while  data transmission as it works as a switching system... of  problem, not in the VRRP system. All the data has been lost
importing data and edit that data
importing data and edit that data   hello sir i have data in excel sheet which contain 2 rows and i want to import that data to ms access and edit that data like adding new columns and new rows and creating new tables
Data Normalization
Data Normalization       In this section you will learn the concepts of data normalization. The most important thing in database designing is to make sure that the data get properly
data processing is
data processing is   data processing is   Data processing is associated with commercial work. Data processing is also referred as Information System. Data processing is basically used for analyzing, processing
data tyape
data tyape   please give me data type of Date
data tyape
data tyape   please give me data type of Date
data tyape
data type of Date  please give me data type of Date
data tyape
data tyape   please give me data type of Date
data tyape
What data tyape a date field req in SQL   please give me data type of Date
data tyape
data type of date in mysql  please give me data type of Date
data type
data type  which data type is used to store video file in mysql databse
Data objects
Data objects   hello,, What are data objects?   hii, Sequences, Views, clusters, Tables, index and cluster are called data objects for a database
Data Generator
Data Generator Data Generator is free open source script that is designed to create the application, which can be used to generate a large sum of data... JavaScript, PHP and MySQL. Characteristics Data generator is browser
data types
data types  Write a short note on data types of Java.   Please visit the following link: Java datatypes
Split Data
Split Data  how to split data from to from e.g. sssss-3100@jdkck i want only 3100 data from that string
no data in db
no data in db  Using the example in "Networking/web-services-database.shtml" managed to do everything as shown above but there is no data in the database. the result is "record inserted". where can the error
Data Retrival
Data Retrival  How to get the output With in 2 mins for more than 13 lakhs records
login data
login data   Hiiii Sir I am doing banking project on Asp.net i have... the data after login i want to show particular data for particular user means if i login i wanna see only myn data how shud i do thanxx in advance
displaying data
displaying data   how to display data from database on jsp using struts2
data update
data update  sir, I have a table consist of huge data.I have displayed that data in table format be side of a table an edit button which will edit the entire data which is retreived .After editing the data i want to save
data update
data update  sir, I have a table consist of huge data.I have displayed that data in table format be side of a table an edit button which will edit the entire data which is retreived .After editing the data i want to save
data update
data update  sir, I have a table consist of huge data.I have displayed that data in table format be side of a table an edit button which will edit the entire data which is retreived .After editing the data i want to save
data update
data update  sir, I have a table consist of huge data.I have displayed that data in table format be side of a table an edit button which will edit the entire data which is retreived .After editing the data i want to save
data update
data update  sir, I have a table consist of huge data.I have displayed that data in table format be side of a table an edit button which will edit the entire data which is retreived .After editing the data i want to save
data update
data update  sir, I have a table consist of huge data.I have displayed that data in table format be side of a table an edit button which will edit the entire data which is retreived .After editing the data i want to save
Advertisements
 

 

 

DMCA.com