How to pass the search criteria parameter.

<%@ taglib uri="" prefix="pg" %>
<pg:pager maxPageItems='10'>
<pg:param name="keywords"/>

StringBuffer sb = new StringBuffer();
sb.append("SELECT USERID, FIRST_NAME, LAST_NAME where 1=1")

String se = request.getParameter("search");
if (se != null)
out.print("<pg:param name='search' value='"+se+"')/>");
String lname = request.getParameter("lname");
if(lname!=null && !lname.equals(""))
sb.append(" AND LAST_NAME LIKE '"+lname+"'");

.. // Get Data from DB and display here. 10 record per page.
<font face=Helvetica size=-1>Result Pages:
<a href="<%= pageUrl %>">[<< Previous ]</a>
<a href="<%= pageUrl %>"><%= pageNumber %></a>
<a href="<%= pageUrl %>">[ Next >> ]</a>

The above code display 10 records at a time. Now when someone search with lastname on search page. And let say they are 14 match the lastname. so my code displays first 10 records search query correctly. And when user click next or 2(Numberic 2 ) to see rest 4 records. 2nd Page don't show remaining 4 records but shows 10 records which is same 2nd page if search was not performed.

thx in advance.
Who is Participating?
objectsConnect With a Mentor Commented:
then you need to pass all fields that arte required. otherwise how can you make the correct query.
looks like it should be passing the lname parameter, and not search.
princehyderabadAuthor Commented:
I have top page [search colum page] and bottom page displays default records. so in default page I'm checking if "search=Y" which is declare in top page.

When somone search and submit it calls the same (default) page but this time it append the query with corresponding search colum.

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

yes, but the lname parameter is needed to do the query.
princehyderabadAuthor Commented:
lname is just given in sample code, but they are actually few more fields.  Can you please kindly put one sample.
I hv been working on this for while still cant find solutions.
princehyderabadAuthor Commented:
U mean pass here as:
<a href="<%= pageUrl %>?lname=<%=lname%>& .....">
thats one way, or use pg:param
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.