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



Home Answers Viewqa JSP-Servlet How to give the value
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Raja
How to give the value
1 Answer(s)      4 years and 9 months ago
Posted in : JSP-Servlet


How to give the value in following query..
"select * from studentinformation where studentid = '?'";

How to give the value into question mark?...

Advertisement
View Answers

February 24, 2010 at 4:10 PM


Hi Friend,

Try the following code:

<%@ page language="java" %>
<%@ page import="java.sql.*" %>

<%!
Connection conn = null;
ResultSet rs =null;
Statement st=null;
String query="";
int cid;
%>
<%
if(request.getParameter("cid")!=null){
cid=Integer.parseInt(request.getParameter("cid"));
}else {
cid=0;
}
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root";, "root");
st = conn.createStatement();
rs = st.executeQuery("select * from student");
%>
<html>
<head>
<script type="text/javascript">

function view(){
var cid=document.getElementById("student").selectedIndex;
window.location.replace("http://localhost:8080/examples/jsp/combo.jsp?cid="+cid);
}
</script>
</head>
<body>
<select id="student" onchange="view(this)">
<option value="0">--Please Select--</option>
<% while(rs.next()){ %>
<option value='<%=rs.getInt("id")%>'><%=rs.getInt("id")%></option>
<%}%>
</select>
<%
rs = st.executeQuery("select * from student where id='"+cid+"'");
%>
<%
String name="";
while(rs.next()){
name=rs.getString("name");
}%>
<input type="text" value="<%=name%>">
</body>
</html>

Thanks


Related Tutorials/Questions & Answers:
How to give the value - JSP-Servlet
How to give the value   How to give the value in following query.. "select * from studentinformation where studentid = '?'"; How to give the value into question mark?...  Hi Friend, Try the following code
How to give value for select in HTML dynamically using javascript
How to give value for select in HTML dynamically using javascript  hi. Consider the situation i am having 2 select options called degree... should be displayed in the dept list. how to do this using javascript
Advertisements
How to give path to the Dfile?
How to give path to the Dfile?  Hello erveryone, I want to make... on sphinx, i have to give path to the sphinx4.jar file which is present in my... you give me the write path, please help me
how to get radio value
how to get radio value    how to retrive the option value and insert the next table pls give example
how to give validation using javascript in swing
how to give validation using javascript in swing   how to give validation using javascript in swing....... can somebody give code for username and password validation using javscript and swing
How to Give button tool tip image
How to Give button tool tip image  In eclipse the same code is not working...not able to point to the image   Please visit the following link: Java Button Tooltip Image
how to give link from jsp to jsp page
how to give link from jsp to jsp page  hi this is my following code... file is Modify but here i have to give modifyUser.jsp file but i don't khow how..." value="Edit" style="background-color:#49743D;font-weight:bold;color:#ffffff
how to give link from jsp to jsp page
how to give link from jsp to jsp page  hi this is my following code... file is Modify but here i have to give modifyUser.jsp file but i don't khow how..." value="Edit" style="background-color:#49743D;font-weight:bold;color:#ffffff
How many ways we can give the output to a browser?
How many ways we can give the output to a browser?  How many ways we can give the output to a browser
how to update the value of jslider
how to update the value of jslider  hello, I want to make a audio player but the jslider is not updating help me
how to update the value of jslider
how to update the value of jslider  hello, I want to make a audio player but the jslider is not updating help me
how to update the value of jslider
how to update the value of jslider  hello, I want to make a audio player but the jslider is not updating help me
how to update the value of jslider
how to update the value of jslider  hello, I want to make a audio player but the jslider is not updating help me
how to update the value of jslider
how to update the value of jslider  hello, I want to make a audio player but the jslider is not updating help me
How to save value in JSP
How to save value in JSP  Employee Name Time-IN Time-OUT... 324 2012-12-12 save i want to save dis value jsp to action ...how can i get all value ..and store..how can its values goes
how to archive cllocation value
how to archive cllocation value  hi, Am working with location based application, need to store cllocation value in array, for that i need to arhive it using NSKeyarchiver... haved searche not net but didnt find anything on how
how to archive cllocation value
how to archive cllocation value  hi, Am working with location based application, need to store cllocation value in array, for that i need to arhive it using NSKeyarchiver... haved searched on net but didnt find anything on how
how to create xls file and give download option using jsp/servlet?
how to create xls file and give download option using jsp/servlet?  Hi, how to create file and give download option to user,so that the user can save the file on defined path
how to send email please give me details with code in jsp,servlet
how to send email please give me details with code in jsp,servlet  how to send email please give me details with code in jsp,servlet
How to move a value in array?
How to move a value in array?   Enter value at the End: 5 Display... value at the End again 8 Display Array Elements Index at [0]0 Index at [1]0 Index at [2]5 Index at [3]8 Enter value at the beginning: 7 Index at [0]7 Index at [1
How to move a value in array?
How to move a value in array?   Enter value at the End: 5 Display... value at the End again 8 Display Array Elements Index at [0]0 Index at [1]0 Index at [2]5 Index at [3]8 Enter value at the beginning: 7 Index at [0]7 Index at [1
Web Service - Which files we have to give to client and how they will use that
Web Service - Which files we have to give to client and how they will use... this web service or want to give it to client , for that which files i have to give. 2) In client side how they will use that, and how they call method from
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations ...","Ajax_Prepaid_GSM_Verification?q="+str,true); xmlhttp.send(); } <...=" + document.getElementById('txtbx').value } <!-- function hideMe(){ // Hide
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations ...","Ajax_Prepaid_GSM_Verification?q="+str,true); xmlhttp.send(); } <...=" + document.getElementById('txtbx').value } <!-- function hideMe(){ // Hide
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations ...","Ajax_Prepaid_GSM_Verification?q="+str,true); xmlhttp.send(); } <...=" + document.getElementById('txtbx').value } <!-- function hideMe(){ // Hide
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations ...","Ajax_Prepaid_GSM_Verification?q="+str,true); xmlhttp.send(); } <...=" + document.getElementById('txtbx').value } <!-- function hideMe(){ // Hide
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations ...","Ajax_Prepaid_GSM_Verification?q="+str,true); xmlhttp.send(); } <...=" + document.getElementById('txtbx').value } <!-- function hideMe(){ // Hide
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations ...=xmlhttp.responseText; } } xmlhttp.open("GET","Ajax_Prepaid_GSM_Verification?q="+str... = lnk.href + "?mdnno=" + document.getElementById('txtbx').value
how to set the value of textfield constant
how to set the value of textfield constant  how to set the value of textfield constant
how to get the checkbox value in jsp
how to get the checkbox value in jsp  how to get the checkbox value in jsp?   JSP CheckBox Example - how to get the checkbox value in jsp
how to select second combobox value .
how to select second combobox value .  I requirement is , i have two combo box, i am selected first combo box value then automatically second combo box value show ,But this both combo box value i retrieves in database. please
Advertisements
 

 

 

DMCA.com