What exactly is the result of the action ?
Why isn't it what you'd expect ?

On a side note, i believe you should test the
request.getParameter("categoy") for null values BEFORE assignig it to a
String.


>
> Hi, I have a jsp page called pager-jdbc.jsp, I don't know
> what's wrong with
> this select option that I did, I want when the user select an
> option the
> same jsp file is called with the category variable set to a
> different value
> .
> <%
>         String requestUri = request.getRequestURI();
>         int indexOfqm = requestUri.indexOf('?');
>         if (indexOfqm != -1)
>                 requestUri = requestUri.substring(0, indexOfqm);
>
>         String category = request.getParameter("category");
> %>
>
> <%
> if (category !=null)
> {
>   category = (String)request.getParameter("flag");
> }
> else //If flag wasn't in the query string, set it to a default value.
> {
>   category = "All"; //Fill in the default value here. I just
> used an empty
> string.
> }
> %>
>
> <center>
>
> <script language="JavaScript">
> function gotoFunction() {
>         self.location =
> document.productGoto.productList.options[document.productGoto.
> productList.selectedIndex].value;
> }
>
> </script>
> <table  width="90%" cellpadding="4">
> <tr>
> <td>
> <FORM NAME="productGoto">
> <FONT FACE="Arial,Helvetica" SIZE="-2">
> Select By Category:
> <SELECT NAME="productList" onChange="gotoFunction()" onBlur="return
> options[0].selected = true">
> <OPTION VALUE="">Select a Category
> <OPTION VALUE="<%= requestUri %>?category=All ">All Categories
> <OPTION VALUE="<%= requestUri %>?category=Computing ">Computing
> </SELECT>
> </FORM>
> </td>
> <td width="100%">
>
> </td>
> </tr>
> </table>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
>
> ==============================================================
> =============
> To unsubscribe: mailto [EMAIL PROTECTED] with body:
> "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set
> JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to