I am developing a blog in java struts I want when to open a post(All record are displayed by the database ) than how to make a link see the next post and the previous post.
public static PostInfo getPrevId(String postUrl) {
PostInfo post = null;
try {
Connection conn = ConnectionManager.getConnection();
PreparedStatement ps = conn.prepareStatement("SELECT posturl FROM blogpost WHERE posturl = ?");
ps.setString(1, postUrl);
ResultSet rs = ps.executeQuery();
rs.afterLast();
rs.previous();
post = new PostInfo(rs.getString("posturl"));
} catch (Exception e) {
e.printStackTrace();
}
return post;
}
Please help me to make the link.