to display single row from database and next to display other question

to display single row from database and next to display other question

Hi all,
I am using JSP with MYSQL backend.
In my project we have 100 questions in database
we have to display first question
on clicking the button it has to display the next question.

i tried it
first question is displayed, but i am facing a problem while retieving the next question in the jsp page.
its giving null.

I am new to jsp. can any one help me please

Thanks in advance,
Usha
View Answers

July 1, 2010 at 3:12 PM

Hi Friend,

Try the following code:

next.jsp:

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

<HTML>
<BODY>
<% int current = 0;
Connection connection = null;
ResultSet rs = null;
%>
<FORM NAME="form1" ACTION="next.jsp" METHOD="get"><%
if (request.getParameter("hidden") != null) {
current = Integer.parseInt(request.getParameter("hidden"));
}
Statement statement = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test";,
"root", "root");
statement = connection.createStatement();
rs = statement.executeQuery("select * from question");
for (int i = 0; i < current; i++) {
rs.next();
}
if (!rs.next()) {
out.println("All questions are over");
} else {
%>

<TABLE>
<TR><TH><%=rs.getString(2)%></TH><TD><input type="text"></TD></TR>
</TR>
</TABLE>
<BR>
<INPUT TYPE="hidden" NAME="hidden" VALUE="<%=current + 1%>">
<INPUT TYPE="submit" VALUE="Next">
</FORM>
<%
}
}
catch (Exception ex) {
}
finally {
rs.close();
statement.close();
connection.close();
}
%>
</FONT>
</FORM>
</body>
</html>

Thanks









Related Tutorials/Questions & Answers:
to display single row from database and next to display other question - JSP-Servlet
to display single row from database and next to display other question ... questions in database we have to display first question on clicking the button it has to display the next question. i tried it first question is displayed
How to Display Next question from database after clicking Next Button using "Arraylist concept"
How to Display Next question from database after clicking Next Button using... = null, question = null; Iterator...(); question
Advertisements
How to display single row from sql server 2005
How to display single row from sql server 2005  I am doing MCA... next names using next button and prev name using prev button. prev button will not work first name and in last name next button will no work. please help me
how to display image and text in single jsp page from the mysql database
how to display image and text in single jsp page from the mysql database  hello please help me to display the image and text in single jsp page from mysql database if have any reference code please send me Thanks in advance
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST  How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST,please send answer as soo as possible
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST
How to Display next Record from Database "On the Click of Next Button" USING... records in index form) to show next data on button click,so that it will goes to next list and sees the index and display another records Please reply. <
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST
How to Display next Record from Database "On the Click of Next Button" USING... records in index form) to show next data on button click,so that it will goes to next list and sees the index and display another records Please reply. <
display multiple image file or pdf file in multiple column of a row from server or database
display multiple image file or pdf file in multiple column of a row from server... in a single row..Suppose I have to display two files in a row then after uploading more files then uploaded file should be display again tow file in another row
display data from database on selecting option of dropdownlist
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   Sir I want to display data from database by just selecting option of dropdown list
display data from database on selecting option of dropdownlist
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   Sir I want to display data from database by just selecting option of dropdown list
display data from database on selecting option of dropdownlist
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   Sir I want to display data from database by just selecting option of dropdown list
display data from database on selecting option of dropdownlist
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   Sir I want to display data from database by just selecting option of dropdown list
how to display records from database
how to display records from database  I want to display records from database in tables, the database is having 2000 records and i want to display 20 records at a time and to use next and previous link buttons to show
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 the hidden text from that row, when onclick on a row of 1- 10
display the hidden text from that row, when onclick on a row of 1- 10  Using JSP: I'm displaying a set of values from the databse in a table rows (1... other row. Really appreciate ur help. Please help me. Here is a dummy code I had
how to display data from database in jsp
how to display data from database in jsp  how to display data from database in jsp
How to retrieve and display image from database in Java?
How to retrieve and display image from database in Java?  Hi, I am writing a web application for reading the data from database and displaying... from database in Java? Thanks   Hi, This question is duplicate
display multiple images from postgres database in jframe
display multiple images from postgres database in jframe  i just want to display multiple images on jframe by firing a query on postgres database
how to display a table from database using servlet
how to display a table from database using servlet  how to display a table with values from servletpage   Hi Friend, Please go through the following link:ADS_TO_REPLACE_1 http://roseindia.net/jsp/servlet-jsp-data
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
Display Data from Database in JSP
; <html> <head> <title>display data from...;To display all the data from the table click here...</h2></TD>..., to show data from the database click on the link that calls another .jsp file named
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.... one.jsp value of 'school' request parameter are comming from the link
How to display data from database in a TableView
How to display data from database in a TableView  I need to populate a TableView (JavaFx) with database items. I designed the TableView in JavaFx... at this. The classes: This is the Class that creates the database data object: import
how to display the selected row from the data table in model panel ??
how to display the selected row from the data table in model panel ??  the below displayed is my datatable:tableDatas.xhtml <rich:dataTable value="#{tableRecordBean.dataList}" var="dataItems" onRowClick="#{rich
how to display data from jsp file into database
how to display data from jsp file into database  this is a jsp file...(); in the below example. the error is "cannot convert from java.sql.Statement...+",'"+email+"')"); out.println("Data is successfully inserted into database
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
image is display from path of mysql database
image is display from path of mysql database  <%@ page import="java.io.,java.sql.,java.util.zip.*" %> <% String saveFile=""; String contentType = request.getContentType(); if((contentType != null)&&
MySql Databse query to fetch results from database and display it in HTML File
MySql Databse query to fetch results from database and display it in HTML File  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have
display database results
display database results  how to display database results using php
retrieving newly added records from mssql database and display in a jsp
retrieving newly added records from mssql database and display in a jsp ... from mssql database table and display those records in a jsp.And i have to delete these 10 records from the jsp and retrieve the next recently added 10 records
display all the values on next page
display all the values on next page  i am inserting values in the database through textboxes and dropboxes, when i am clicking on submit button those values are inserting in the database and i am moving on another page after
Display Data from Database in JSP
Display Data from Database in JSP   ... and execute query to display data from the specified table.  Before...;head> <title>display data from the table using jsp</title> <
How to display image in jsp from database using Servlet?
How to display image in jsp from database using Servlet?  Hi, How to display image in jsp from database using Servlet? Thanks   Hi, You will find code and example program at Retrieve image from database using Servlet
how to display values from database into table using jsp
how to display values from database into table using jsp  I want to display values from database into table based on condition in query, how... the values from database based on the bookname or authorname entered must be display
display data from database in textbox when id entered in textbox
display data from database in textbox when id entered in textbox  i wanted to enter data in textbox .depending on entered data in textbox data from database should be displayed dynamically in textbox
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
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
How to retrieve single row from MSSQL
How to retrieve single row from MSSQL  Hello sir, Sir i... has to display patient details accordingly,that what is present in his row.I mean only his row has to be displayed in the next Jpanel within same window.I
How to retrieve single row from MSSQL
How to retrieve single row from MSSQL  Hello sir, Sir i... has to display patient details accordingly,that what is present in his row.I mean only his row has to be displayed in the next Jpanel within same window.I
How to retrieve single row from MSSQL
How to retrieve single row from MSSQL  Hello sir, Sir i... has to display patient details accordingly,that what is present in his row.I mean only his row has to be displayed in the next Jpanel within same window.I
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... project next week..i want to se the snapshots of the output   Please visit
Retrieve image from database using servlet and display in JSP
Retrieve image from database using servlet and display in JSP  Hi, I... to use MySQL Database from JSP page. How to retrieve image from database using servlet and display in JSP? Thanks
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...simple web appllication to insert, update or display from database  hello sir i am using netbeans 5.5 ide with tomcat and oracle 9 i as database
Write a question to display the follwing
Write a question to display the follwing  Write a Java program to display a pattern?   String str = ""; int count = 4; for( int i=9,j...++; } System.out.print(str);   class Display { public void
Write a query to display a row using index
Write a query to display a row using index  Write a query to display a row using index
Select Employee and display data from access database in a jtable
Select Employee and display data from access database in a jtable  I... a employee's name from a comboBox and the jtable will be filled with all... name of the customer is stored in a access database. Below is how it should
display
display  please tell me how to display the content from database.. if we click on any image using servlets/jsp...please
How to show next question from database on the click of next button..(Struts & Hibernate)
How to show next question from database on the click of next button..(Struts.... Problem.: When m clicking my next button it is not showing another question from "cards" table. passing parameter from viewalllists.jsp to flashPage.jsp

Ads