fetch 2nd row, 3rd row....200 row of a table in oracle by servlet
You can use a count
variable which gets passed as a request attribute.For example:
NewServlet.java
String count = request.getParameter("count");int c = 0;String query;if(count != null && count.matches("\\d+")){ c = Integer.parseInt(count); query = "SELECT * FROM abc ORDER BY 'F','S' OFFSET "+String.valueOf(c)+" ROWS FETCH NEXT 1 ROWS ONLY";}else{ query = "SELECT * FROM abc ORDER BY 'F','S' FETCH FIRST 1 ROWS ONLY";}request.setAttribute("count",++c);
display.jsp
<input type="text" name="count" value="<%=(Integer)request.getAttribute("count")%>" style="display:none;">
home.jsp
<form action="NewServlet" method="post"> <input type="submit" value="NEXT"> </form>
Remove the count
input from home.jsp
so that the first time you call the servlet
the count
parameter will be null.