How to pass the search criteria parameter.

<%@ taglib uri="http://jsptags.com/tags/navigation/pager" 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+"'");
}

..
...
}
<ex:searchresults>
<pg:item>
..
.. // Get Data from DB and display here. 10 record per page.
...
</pg:item>
</ex:searchresults>
..
<pg:index>
<font face=Helvetica size=-1>Result Pages:
<pg:prev>
<a href="<%= pageUrl %>">[<< Previous ]</a>
</pg:prev>
<pg:pages>
<a href="<%= pageUrl %>"><%= pageNumber %></a>
</pg:pages>
<pg:next>
<a href="<%= pageUrl %>">[ Next >> ]</a>
</pg:next>
</pg:index>
</pg:param>
</pg:pager>

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.
princehyderabadAsked:
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.
0
 
objectsCommented:
looks like it should be passing the lname parameter, and not search.
0
 
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.

0
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.

 
objectsCommented:
yes, but the lname parameter is needed to do the query.
0
 
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.
0
 
princehyderabadAuthor Commented:
U mean pass here as:
<a href="<%= pageUrl %>?lname=<%=lname%>& .....">
0
 
objectsCommented:
thats one way, or use pg:param
0
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.