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



Home Answers Viewqa JSP-Servlet How to give the value

Have Programming Question? Ask it here!
 
 
 


Raja
How to give the value
1 Answer(s)      4 years and 2 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 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 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 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 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 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 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
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 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
How can you give up Free Swtor Credits?
How can you give up Free Swtor Credits?  How can you give up Free Swtor Credits?   Hello everyone, the striking news is that there will be a first-time Super Promo at swtor2credits. Twenty portions of 500K swtor credits
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 give tint color effect
How to give tint color effect Give the tint effect to your photo by this example. This effect will apply on the tree picture so follow this tutorial to learn complete. Take a Picture: Take any picture
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
How to get enum value in Java
How to get enum value in Java  Hi all, i am looking for a solution to get an enum value from index in Java. Please suggest. Thanks
How to change the checkbox value dynamically.
How to change the checkbox value dynamically.  Hi, I am using struts 1.2 checkbox tag. Requirement is on page load the value must be "true... i am unchecked the box it is showing the value as"true". please suggest me
How to pass value of a link to a textfield
How to pass value of a link to a textfield  Dear Sir, in my project I'm initially making a value of the textfield as a link. Now, I want to pass the value of the link in the textfield after clicking the link and dont want to open
how to set value of dropdown list
how to set value of dropdown list  Hello Sir, I'd solved the earlier problems somehow but now this time another problem arised when I want to pass the value from a link to a dropdown list. I want to set the dropdown list selected
how to set value of dropdown list
how to set value of dropdown list  Hello Sir, I'd solved the earlier problems somehow but now this time another problem arised when I want to pass the value from a link to a dropdown list. I want to set the dropdown list selected
how to insert value in dynamic table
how to insert value in dynamic table  i am creating a project in Training and Placement.i have a created a company register part where i create... student table. and company and year value i'm getting through company table.but apache
How to find maximum value in ArrayList
How to find maximum value in ArrayList  **Sir i am writing below code but its not working.i don't know how to implement logic my requirement.My requirement is find maximum value in userdefined objects and dispaly that object
How to find maximum value in ArrayList
How to find maximum value in ArrayList  **Sir i am writing below code but its not working.i don't know how to implement logic my requirement.My requirement is find maximum value in userdefined objects and dispaly that object
How to find maximum value in ArrayList
How to find maximum value in ArrayList  **Sir i am writing below code but its not working.i don't know how to implement logic my requirement.My requirement is find maximum value in userdefined objects and dispaly that object
How to find maximum value in ArrayList
How to find maximum value in ArrayList  **Sir i am writing below code but its not working.i don't know how to implement logic my requirement.My requirement is find maximum value in userdefined objects and dispaly that object
How to convert EBCDIC format value into ASCII format value in java
How to convert EBCDIC format value into ASCII format value in java  how to convert EBCDIC data format into ASCII format data using java Use Case:I... to convert EBCDIC data value into ASCII data values. Please help me to solve
i need project for shopping cart in struts 1 with the oracle database and give clear explanation for how to execute it in my eclipse
and give clear explanation for how to execute it in my eclipse  i need a project for shopping cart in struts1 with the oracle database and give clear explanation for how to execute it in my eclipse and where to copy the files as i am
give idea
give idea  how to plot graph in java   Please visit the following link: http://www.roseindia.net/java/example/java/swing/draw-simple-bar-chart.shtml
How to pass the value of Selected Value of combo box into sql ??
How to pass the value of Selected Value of combo box into sql ??  My SQL Database Name is MHS, user=root, password=admin,table name is sub_comb... submit i want to display other field. how to get it?? plz help me
How do you pass a variable by value?
How do you pass a variable by value?  How do you pass a variable by value
how to assign javascript variable value to a jsp variable
how to assign javascript variable value to a jsp variable  how to assign javascript variable value to a jsp variable
how to display textbox value based on selected option value?
how to display textbox value based on selected option value?  Hi,I... on first value I finished above code. ID: xx Name:xx xx is baesd on second and first value. But it is that l can't do that. now, l post my code
 

 

 

DMCA.com