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

Ads

 
 
 

Share on Google+Share on Google+

usha
to display single row from database and next to display other question
1 Answer(s)      6 years and 11 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
Ads
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

Ads









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
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 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
Tutorials   
Java Spring Hibernate Struts Training fat image from db fat image from db fat image from db fat image from db unable to get value returned from javascript variable in page How to change image size before adding to mysql using jsp Design a registration.jsp page with input for user registration details Cart Quantity jsp servlet coding issue servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? image pdf marking pdf marking Multiple image upload using JSP Read code from excel sheet and upload into database using JSP Student java about search engine Convert BLOB to PDF and save it to a location how to copy files from remote to local machine using SFTP SSL in java? Like Team viewer Socket and Servert -Jsp how to copy files from remote location to local using java? How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java how to create SOAP based web service in java? how to fetch data from mysql database table and draw a bar chart on that data using in jsp how to create users in LDAP using java? how to authenticate user using TIVOLI api in java? how to create users using IBM Tivoi API in jsp/servelet? Java/J2ee Please explain this code as many packages and classes are unknown to me .! how to download the uploaded folder files using jsp Login Query image is display from path of mysql database please reply the code to store dynamic fields in database? Reloading issue in jsp How to get Button Id ? calling one jap page from another jsp page login login Problem to get connection from DAO class to JDBC Page Loading Time Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below Sending hidden values

Ads

 
Advertisement null

Ads