#1
  1. PHP & Java Error Master
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    My Computer
    Posts
    1,219
    Rep Power
    0

    Getting 'cannot resolve symbol'


    Code:
    if(request.getParameterValues("del_ids") != null)
    {
    	String[] del_ids = request.getParameterValues("del_ids");
    }
    ...
    for(int i = 0; i < del_ids.length; i++)
    {
    	count++;
    }
    The error is pointing to del_ids.length

    Anyone know why?

    Here's my whole code:
    Code:
    <% // do_del.jsp %>
    <%@ page import="java.util.*, java.text.DateFormat, java.text.DateFormatSymbols, java.sql.*,javax.sql.*,oracle.jdbc.pool.*" %>
    <%@ include file="access.jsp" %>
    <%@ include file="../global.jsp" %>
    <%@ include file="../header.jsp" %>
    <%
    if(request.getParameterValues("del_ids") != null)
    {
    	String[] del_ids = request.getParameterValues("del_ids");
    }
    
    String do_del = null;
    int count = 0;
    Connection conn = null;
    
    if(request.getParameter("delete") != null)
    {
    	do_del = request.getParameter("delete");
    }
    
    if(do_del == null)
    {
    	String these = null;
    	// Print the confirmation message
    	for(int i = 0; i < del_ids.length; i++)
    	{
    		count++;
    	}
    	if(count > 1)
    	{
    		these = "these " + count + " events?";
    	}
    	else
    	{
    		these = "this " + count + " event?";
    	}
    	out.println("<center><font size=\"2\" face=\"Arial\">Are you sure you with to delete " + these);
    }
    %>
  2. #2
  3. PHP & Java Error Master
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    My Computer
    Posts
    1,219
    Rep Power
    0
    Also, if i delcare String[] del_ids = null; outside the if, I get "NullPointerException".
    Doesn't have any line #s, or any indication as to where the problem is.
    Last edited by StevenC; July 3rd, 2003 at 09:23 AM.
  4. #3
  5. PHP & Java Error Master
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    My Computer
    Posts
    1,219
    Rep Power
    0
    No one?
  6. #4
  7. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    The reason you are getting a unresolved symbol error is because the del_ids variable is declared in the if block and is not available outside the if, which you seem to be aware of because of your second question.

    As for your second question, the array will be null if there are no parameters by that name in the request. Are you sure you are passing those values? Also, you aren't doing something like this are you?
    Code:
    String[] del_ids;
    if(request.getParameterValues("del_ids") != null)
    {
    	String[] del_ids = request.getParameterValues("del_ids");
    }
    That would cause a scope problem and should be written like this:
    Code:
    String[] del_ids;
    if(request.getParameterValues("del_ids") != null)
    {
    	del_ids = request.getParameterValues("del_ids");
    }
    Last edited by Nemi; July 3rd, 2003 at 09:57 AM.
  8. #5
  9. PHP & Java Error Master
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    My Computer
    Posts
    1,219
    Rep Power
    0
    This is the exact code:
    Code:
    String[] del_ids = null;
    if(request.getParameterValues("del_ids") != null)
    {
    	del_ids = request.getParameterValues("del_ids");
    }
    And i'm 99% sure the values are being passed.
    on the submitting page, there's a number of checkboxes. all with the same name.
  10. #6
  11. PHP & Java Error Master
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    My Computer
    Posts
    1,219
    Rep Power
    0
    lol, stupid me.

    after an insepction of the html source, i was getting del_ids, when it's delete_ids

    Thx again
  12. #7
  13. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Just a suggestion. This is a little cleaner and less prone to errors:

    Code:
    String[] del_ids = request.getParameterValues("del_ids");
    if( del_ids != null)
    {
    	... do loopy stuff ...
    }
    -james

IMN logo majestic logo threadwatch logo seochat tools logo