Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Product listing A-Z and limit results entries

Status
Not open for further replies.

garfield11

IS-IT--Management
Jul 4, 2002
44
SG
Hi all,

Can anyone help me with this.

I had a page called viewProd.jsp and i wanna my page to work like this:

Title: View Products
___________________________________________________

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
___________________________________________________

Found 18 results

1. ------
2. ------
3. ------
4. ------
5. ------

<< 1 | 2 | 3 >> <-- page number

List from A-Z and when a user clicks on A, below will display all products starting with the letter A from the database. If no results found, a message will be shown.

Also, I wanna limit the result entries to 5 per page. Lets say product starting with letter A found 18 results, i want first 5 items to be displayed 1st: that's page 1 and when click page 2 next 5 will be displayed and so on.

Is it possible to do that in JSP/using servlets?

Thanks
 
yes it is but the code is going to be one hellowa long one. Known is handfull, Unknown is worldfull
 
The following will accomplish the first part of your task.

On your page put a series of links


<tr style=&quot;font-family:arial; font-size:110%&quot;>
<td align=&quot;CENTER&quot; colspan=&quot;2&quot; >
<a href=&quot;YourPage.jsp?Alpha=A&quot; >A</a>  
<a href=&quot;YourPage.jsp?Alpha=B&quot; >B</a>  
<a href=&quot;YourPage.jsp?Alpha=C&quot; >C</a>  
<a href=&quot;YourPage.jsp?Alpha=D&quot; >D</a>  
<a href=&quot;YourPage.jsp?Alpha=E&quot; >E</a>  
<a href=&quot;YourPage.jsp?Alpha=F&quot; >F</a>  
<a href=&quot;YourPage.jsp?Alpha=G&quot; >G</a>  
<a href=&quot;YourPage.jsp?Alpha=H&quot; >H</a>  
<a href=&quot;YourPage.jsp?Alpha=I&quot; >I</a>  
<a href=&quot;YourPage.jsp?Alpha=J&quot; >J</a>  
<a href=&quot;YourPage.jsp?Alpha=K&quot; >K</a>  
<a href=&quot;YourPage.jsp?Alpha=L&quot; >L</a>  
<a href=&quot;YourPage.jsp?Alpha=M&quot; >M</a>  
<a href=&quot;YourPage.jsp?Alpha=N&quot; >N</a>  
<a href=&quot;YourPage.jsp?Alpha=O&quot; >O</a>  
<a href=&quot;YourPage.jsp?Alpha=P&quot; >P</a>  
<a href=&quot;YourPage.jsp?Alpha=Q&quot; >Q</a>  
<a href=&quot;YourPage.jsp?Alpha=R&quot; >R</a>  
<a href=&quot;YourPage.jsp?Alpha=S&quot; >S</a>  
<a href=&quot;YourPage.jsp?Alpha=T&quot; >T</a>  
<a href=&quot;YourPage.jsp?Alpha=U&quot; >U</a>  
<a href=&quot;YourPage.jsp?Alpha=V&quot; >V</a>  
<a href=&quot;YourPage.jsp?Alpha=W&quot; >W</a>  
<a href=&quot;YourPage.jsp?Alpha=X&quot; >X</a>  
<a href=&quot;YourPage.jsp?Alpha=Y&quot; >Y</a>  
<a href=&quot;YourPage.jsp?Alpha=Z&quot; >Z</a>  
</td>
</tr>

Include java such as this on your page.


String Alpha = (request.getParameter(&quot;Alpha&quot;) == null ? &quot;A&quot; : request.getParameter(&quot;Alpha&quot;));
String query = &quot;SELECT whatever, whateverelse FROM products WHERE productname LIKE('&quot; + Alpha + &quot;%')&quot; ;

Then execute the query. This works with SQL Server. Other databases may require some change in the query but the principal should work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top