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



Home Answers Viewqa JSP-Servlet to display single row from database and next to display other question
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


usha
to display single row from database and next to display other question
1 Answer(s)      4 years and 6 months ago
Posted in : JSP-Servlet


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

Advertisement
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 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 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... 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
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 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
how to display data from database in jsp
how to display data from database in jsp  how to display data from database in jsp
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 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 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 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: http://roseindia.net/jsp/servlet-jsp-data-list.shtml Thanks
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
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
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
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 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
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
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 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
Modifying a single row of database based on selection in jsp
Modifying a single row of database based on selection in jsp  Hi guys, i have a problem, I am Fetching the results from database and displaying... or delete the selected row and update to database.. Please provide me a solution
Advertisements
 

 

 

DMCA.com