Oh ok! Sorry for the explanation.

Respecting the NPE... perhaps it is happening before you the try catch
block...
That work around you implemented works fine so go ahead...
Good luck!


> -----Mensaje original-----
> De:   Venkat [SMTP:[EMAIL PROTECTED]
> Enviado el:   viernes 14 de marzo de 2003 11:43
> Para: [EMAIL PROTECTED]
> Asunto:       Re: Null pointer Exception while sending multiple list
> options
> 
> Hi,
> Thanks for the info. I know that it return you a string array if they
> selected and if not selected it return you a null.
> 
> But actually what i want to do is
> User MUST select at least one values.This is a mandatory field.
> I want to catch exception if user does'nt select any thing in server side.
> Ok i can do it using client side but i am not relie completely on client
> code.So i have to check in serverside as well.
> 
> Ok back to my problem if user doesn't selects any thing i am getting null
> pointer exception and i want to catch this and do some prosses.
> 
> I got a work around.
> Enumeration enum=reques.getParameterNames();
> This will retrun you all the parameters
> then by checking wether there is a parameter with the name prog_name i am
> proceding further.
> 
> But i didn't understand why can't i catch the nullpointer when i used the
> try catch block?
> 
> Thanks for any help
> venkat
> 
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED] Behalf Of Francisco Manuel Mart�nez
> Su�rez
> Sent: Friday, March 14, 2003 3:57 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Null pointer Exception while sending multiple list options
> 
> 
> Loading values into a select field doesn�t set the value of it. So if the
> user doesn�t choose anything, the onChange event is not sent to the select
> field and when submit, the field prog_name has no value. I can�t remember
> if
> not having value makes the field not to be included in the url as
> parameter.
> But if no value is selected you can�t ask for them. Ask first for the
> existence of the parameter, then for its values. Here is a reference for
> that method in javax.servlet.ServletRequest interface.
> 
> REFERENCE________________________
> getParameterValues
> public java.lang.String[] getParameterValues(java.lang.String name)
>         Returns an array of String objects containing all of the values
> the
> given request parameter has, or null if the parameter does not exist. For
> example, in an HTTP servlet, this method returns an array of String
> objects
> containing the values of a query string or posted form.
>         If the parameter has a single value, the array has a length of 1.
> Parameters:
>         name - a String containing the name of the parameter whose value
> is
> requested
> Returns:
>         an array of String objects containing the parameter's values
> See Also:
>         getParameter(java.lang.String)
> <../../javax/servlet/ServletRequest.html>
> 
> 
> 
> 
> 
> 
> > -----Mensaje original-----
> > De:   Venkat [SMTP:[EMAIL PROTECTED]
> > Enviado el:   viernes 14 de marzo de 2003 10:18
> > Para: [EMAIL PROTECTED]
> > Asunto:       Null pointer Exception while sending multiple list options
> >
> > Hi all,
> > I am sending multiple list options from one jsp to another.
> >
> > in my first jsp i am retrieving values from db and and displaying to
> user
> > to
> > select them.
> > <SELECT NAME="prog_name" SIZE=3 MULTIPLE>
> >
> > while(rs.next()){
> > String str=rs.getString("prog_name");
> > out.println("<OPTION VALUE="+str+">"+str+"</OPTION>");
> > }
> > </select>
> >
> > I am retrieveing the selected (more than one or at least one)which user
> > selects to my second jsp page
> >
> >
> > try{
> > String[] prog=null;
> > prog=request.getParameterValues("prog_name");
> > }catch(Exception e){}
> >
> >
> > this works fine when user select at least one value.But if he doesn't
> > selects anything
> > i am getting null pointer exception.
> >
> > Can any one help me where i went wrong.
> >
> > Thanks in advance
> > venkat
> >
> >
> ==========================================================================
> > =
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> > DIGEST".
> >
> > Some relevant archives, FAQs and Forums on JSPs can be found at:
> >
> >  http://java.sun.com/products/jsp
> >  http://archives.java.sun.com/jsp-interest.html
> >  http://forums.java.sun.com
> >  http://www.jspinsider.com
> 
> =========================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> 
> Some relevant archives, FAQs and Forums on JSPs can be found at:
> 
>  http://java.sun.com/products/jsp
>  http://archives.java.sun.com/jsp-interest.html
>  http://forums.java.sun.com
>  http://www.jspinsider.com
> 
> ==========================================================================
> =
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> 
> Some relevant archives, FAQs and Forums on JSPs can be found at:
> 
>  http://java.sun.com/products/jsp
>  http://archives.java.sun.com/jsp-interest.html
>  http://forums.java.sun.com
>  http://www.jspinsider.com

==========================================================================To 
unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com

Reply via email to