Home Answers Viewqa JSP-Servlet data are not display in JSP from database

 
 


Vijay
data are not display in JSP from database
1 Answer(s)      3 years and 2 months ago
Posted in : JSP-Servlet


i want to finding some data through a SQL query from SQL server database to a JSP page based on some condition which i specfied in parameters. but it is not going in while loop.
one.jsp

<%
String school=request.getParameter("school");
out.println(school);
String class_name=(String)request.getParameter("class_name");
String from_year=(String)request.getParameter("from_year");
String to_year=(String)request.getParameter("to_year");
Connection con = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
con = DriverManager.getConnection("jdbc:odbc:sql");
System.out.println("Connection created");
Statement st=con.createStatement();
String query="select * from Result where school=('"+school+"') and (year='"+from_year+"') and (year='"+to_year+"')";
ResultSet rs=st.executeQuery(query);
System.out.println("now data in rs.....");
System.out.println("now going to rs block............");
while(rs.next())
{
System.out.println("yes...now in rs block............");
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
System.out.println(rs.getString(3));
System.out.println(rs.getString(4));
System.out.println(rs.getString(5));
}
rs.close();
con.close();
}
catch(Exception e)
{
out.println(e);
}
%>


value of 'school' request parameter are comming from the link of this jsp page. like..
<a href="indus.jsp?value=result&&school=indus" class="smalltext">School Result</a>
and three request parameters 'class', 'from_year', 'to_year' are the value of three combo boxes. all request parameters are received in this jsp page.

.
but when i used this parameters on a criteria i am not finding any data.
it go only upto
now data in rs
now going to rs block

but it is not going in
while(rs.next())
{
..
.
..
}
sql server database having this fields- year,class, subject, total_students, passout_students, school.

but when i use this query it goes fine.
String query="select * from Result where school=('"+school+"') ";

please suggest.
View Answers

March 23, 2010 at 4:44 PM


Hi Friend,

Try the following code:

1)form.jsp:

<html>
<script>
function sendData(){
var sch=document.form.school.value;

var cla=document.form.class_name.value;
var y1=document.form.from_year.value;
var y2=document.form.to_year.value;
window.open("result.jsp?school="+sch+"&&class_name="+cla+"&&from_year="+y1+"&&to_year="+y2);
}
</script>
<form name="form" >
<table>
<tr><td>School</td><td><input type="text" name="school"></td></tr>
<tr><td>Class</td><td><select name="class_name">
<%
for(int i=1;i<=12;i++){
%>
<option value="<%=i%>"><%=i%></option>
<%
}
%>
</select></td></tr>
<tr><td>From Year</td><td><select name="from_year">
<%
for(int i=2000;i<=2010;i++){
%>
<option value="<%=i%>"><%=i%></option>
<%
}
%>
</select></td></tr>
<tr><td>To Year</td><td><select name="to_year">
<%
for(int i=2000;i<=2010;i++){
%>
<option value="<%=i%>"><%=i%></option>
<%
}
%>
</select></td></tr>
<tr><td><input type="button" value="Result" onclick="sendData();"></td></tr>
</table>
</form>
</html>

2)result.jsp:

<%@page import="java.sql.*"%>
<%
String school=request.getParameter("school");
out.println(school);
String class_name=(String)request.getParameter("class_name");
String from_year=(String)request.getParameter("from_year");
String to_year=(String)request.getParameter("to_year");
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root";, "root");
System.out.println("Connection created");
Statement st=con.createStatement();
String query="SELECT * FROM student WHERE year BETWEEN '"+from_year+"' AND '"+to_year+"' and school='"+school+"'";
ResultSet rs=st.executeQuery(query);
System.out.println("now data in rs.....");
System.out.println("now going to rs block............");
while(rs.next())
{
System.out.println("yes...now in rs block............");
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
System.out.println(rs.getString(3));
System.out.println(rs.getString(4));
System.out.println(rs.getString(5));
}
rs.close();
con.close();
}
catch(Exception e)
{
out.println(e);
}
%>

For more information, visit the following link:

http://www.roseindia.net/jsp/

Thanks









Related Pages:
how to display data from database in jsp
how to display data from database in jsp  how to display data from database in jsp
data are not display in JSP from database - JSP-Servlet
data are not display in JSP from database   i want to finding some data through a SQL query from SQL server database to a JSP page based on some... of this jsp page. like.. School Result and three request parameters 'class', 'from
Display Data from Database in JSP
, to show data from the database click on the link that calls another .jsp file named...; <html> <head> <title>display data from...;To display all the data from the table click here...</h2></TD>
how to display data from jsp file into database
how to display data from jsp file into database  this is a jsp file...+",'"+email+"')"); out.println("Data is successfully inserted into database...(); in the below example. the error is "cannot convert from java.sql.Statement
Display Data from Database in JSP
Display Data from Database in JSP   ... and execute query to display data from the specified table.  Before.... This is first jsp page that has a link 'show data from table', user can show
jfreechart display from access database data.
jfreechart display from access database data.  I have made a database... to retrieve the data from the access database using prepared statement and then display the bar graph using jfreechart API .This whole retrieval and display of chart
jsp code for display of data from database and snap shot of the output
jsp code for display of data from database and snap shot of the output  i am using JSP.i want to insert data into database and also want to display... the following link: http://www.roseindia.net/jsp/displaydatafrom_database1.shtml
Dynamic retrieval od data from database and display it in the table at jsp
the data from the mysql database... pls its urgent.. help me frnds....   Here is a jsp code that retrieves the data from the database and display...Dynamic retrieval od data from database and display it in the table at jsp 
display date to jsp from database
display date to jsp from database   display date to jsp from database to calender if the start date and end date is available than calender date... not available in database field than show in green color and clickable. NOTE :- Date
display data from database on selecting option of dropdownlist
display data from database on selecting option of dropdownlist   Sir I want to display data from database by just selecting option of dropdown list... is that to display image from database in a grid format or in a fixed column and row
display data from database on selecting option of dropdownlist
display data from database on selecting option of dropdownlist   Sir I want to display data from database by just selecting option of dropdown list... is that to display image from database in a grid format or in a fixed column and row
display data from database on selecting option of dropdownlist
display data from database on selecting option of dropdownlist   Sir I want to display data from database by just selecting option of dropdown list... is that to display image from database in a grid format or in a fixed column and row
display data from database on selecting option of dropdownlist
display data from database on selecting option of dropdownlist   Sir I want to display data from database by just selecting option of dropdown list... is that to display image from database in a grid format or in a fixed column and row
how to display a table from database using servlet
how to display a table from database using servlet  how to display... the following link: http://roseindia.net/jsp/servlet-jsp-data-list.shtml Thanks...://roseindia.net/jsp/servlet-jsp-data-list.shtml Thanks
how to display data from database according to entered value in search field
how to display data from database according to entered value in search...(); System.out.println("Disconnected from database"); } catch (Exception e...://java.sun.com/jsp/jstl/core"%> <%@taglib prefix="sql" uri="http://java.sun.com
Display data
Display data  after successful login how i can fetch my account information from sql database
simple web appllication to insert, update or display from database - JSP-Servlet
in which we can insert, update or delete data from database. i can also display database content on jsp page. please send complete code. thank you mani saurabh...simple web appllication to insert, update or display from database  
displaying data retrieved from a database in a jsp page
displaying data retrieved from a database in a jsp page  the page should display username, emailid, telephone in addition to tthe tagline however... sql = "select billid, customerid, billdate, status from customerbills where
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want to insert data into database and also want to display the things i have entered.../WebSevices/19592-retriving-data-from-sql-server-using-jsp-code-and-placing-them
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want to insert data into database and also want to display the things i have entered.../WebSevices/19592-retriving-data-from-sql-server-using-jsp-code-and-placing-them
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want to insert data into database and also want to display the things i have entered.../WebSevices/19592-retriving-data-from-sql-server-using-jsp-code-and-placing-them
How to show data from database in textbox in jsp
How to show data from database in textbox in jsp   How to show data from database in textbox in jsp   Here is an example that retrieve the particular record from the database and display it in textbox using JSP. <
display
display  please tell me how to display the content from database.. if we click on any image using servlets/jsp...please
Getting Textbox data from database
data from database and display it on the textboxes. <%@page language="java...Getting Textbox data from database  When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown
Getting Textbox data from database
;Here is a jsp code that retrieves data from database and display...Getting Textbox data from database  When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown
JSP Get Data From Database
JSP Get Data From Database In this section we will discuss about how to get data from database using JSP. To get data from database to a JSP page we... example which lets you understand to fetch data from database in JSP
display data from a table in Access Database in a HTML page
display data from a table in Access Database in a HTML page  how to display data from a table in Access Database in a HTML page in a Java Program
how to display data from mysql table in text box using jsp??
how to display data from mysql table in text box using jsp??  <p>hi, i have a written a code to display data from a mysql table into txtboxes... at line: 113 in the jsp file: /Cat1.jsp The local variable v_RGPC may not have
dynamic retrivel of data from mysql database in table format at jsp
the data from database and display it as table format in jsp... For example, i have...dynamic retrivel of data from mysql database in table format at jsp  ... of A1 should be retrived from database and display it in the respective textbox
selecting data from database
selecting data from database  how to select data from database using Dao in struts   Hi, You have to load the data from database using hibernate and send the data in a Java file object to jsp page. Please read at http
Display Data from Database in JSF Application
Display Data from Database in JSF Application  ... data from database in JSF application. Developing JSF  Application In this section, we are going to display data from database in JSF based web
SEARCHING THE DATA FROM DATABASE AND DISPLAY THE SEARCHED DATA IN HTML PAGE
SEARCHING THE DATA FROM DATABASE AND DISPLAY THE SEARCHED DATA IN HTML PAGE  pls help me....in this i want to search books from the database... the user specified $data = mysql_query("SELECT * FROM book WHERE upper($field
Data needs to be gathered in XML file from the database (MySql) using JSP
Data needs to be gathered in XML file from the database (MySql) using JSP ... data regarding particular id from the database table. Data needs to be gathered in XML file from the database (MySql) using appropriate JSP/Java Bean functions
how to display data into textboxes which is retrieved from the database
how to display data into textboxes which is retrieved from the database  I would like to know how to display data into textboxes which is retrieved from database in jsf. could you please provide a small example of how to do
how to display data into textboxes which is retrieved from the database
how to display data into textboxes which is retrieved from the database  I would like to know how to display data into textboxes which is retrieved from database in jsf. could you please provide a small example of how to do
how to display data into textboxes which is retrieved from the database
how to display data into textboxes which is retrieved from the database  I would like to know how to display data into textboxes which is retrieved from database in jsf. could you please provide a small example of how to do
use data from database table as hyperlink value - JSP-Servlet
use data from database table as hyperlink value  I'm creating a web page that allows user to search my database. The page will display partial results of my database, then the first column of the resultset was converted
How to read and display data from a .properties file from a jsp page
How to read and display data from a .properties file from a jsp page ... the data from this .properties file and display it in table format. Ex:by using... = DEDCHGG_PWDP and goes on... I have to create a jsp page to show these data
Retrive values from an arraylist and display in a jsp?
Retrive values from an arraylist and display in a jsp?  Hi, I need help in jsp to display values of an ArrayList in jsp. There is a java file...") != null) { Open connection to the database; Read parameters from
how to store the data in a array retrived from the database - JSP-Servlet
how to store the data in a array retrived from the database  hi... in database,and i need to disply all the employees record in a single jsp. pls can any...: http://www.roseindia.net/jdbc/display-data-database.shtml Even though
Retrive values from an arraylist and display in a jsp?
Retrive values from an arraylist and display in a jsp?  Hi, I need help in jsp to display values of an ArrayList in jsp. There is a java file...") != null) { Open connection to the database; Read parameters from
Select Employee and display data from access database in a jtable
Select Employee and display data from access database in a jtable  I... server, and implement the needed data objects in a database server. The clients... a employee's name from a comboBox and the jtable will be filled with all
use data from database as hyperlink and pass the data in the hyperlink
use data from database as hyperlink and pass the data in the hyperlink  Hi Friends, I am using the data from database as hyperlink and pass the data... and display tag property I have displayed a column data as hyperlink. I want to pass
Display Data from database in Popup Window Using Ajax in JSP
Display Data from database in Popup Window Using Ajax in JSP...; to  retrieve the data from database of selected user.  <%@ ...;. Retrieve all the record from the database and display on the pop up
dynamic retrival of data from mysql database to dropdownlist in jsp
dynamic retrival of data from mysql database to dropdownlist in jsp  ... database to the dropdownlist in jsp. Example: 1st i want to display the list... be retrived from the database and display in the textbox as default value... pls its
Search data from database - Java Beginners
searching)in name text box than all data should be displayed in another page related to user name. (means search all field from database and display using...Search data from database  Hi Deepak, This is not correct code
How to display data fom MySQL DataBase-table in to JSP file by submitting a value in combobox.
How to display data fom MySQL DataBase-table in to JSP file by submitting... have to display the Nodename and packageno. i.e.,select nodename,packageno from... DataBase/DB Name:lokesh; Table Name:TR_list; columns:nodename,packageno,TR
How to display data in jsp from dao using java beans?
How to display data in jsp from dao using java beans?  Hi I need to display data in jsp pulling from dao using java beans, Please can anyone give me the sample application with above topics. Any help would be highly appreciated
To retrive data from database - Struts
To retrive data from database  How to get values ,when i select a select box in jsp and has to get values in textbox automatically from database? eg... come to jsp page automatically from database
how to get the data from database&how to display the database data in jsf - Java Server Faces Questions
how to get the data from database&how to display the database data in jsf  Hi, 1.how to get the data from database. 2.how to display the database... and to display the data from database in jsf visit to : http://www.roseindia.net/jsf

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.