error :java.lang.NullPointerException in searchuser.jsp page

Discussion in 'JSP' started by guravharsha, Jul 10, 2008.

  1. guravharsha

    guravharsha New Member

    Joined:
    Jun 10, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    I am creating the updateuser.jsp page. For that I create search.jsp where one can serch users and after submitting this page.it should display the updateuser.jsp page where I can update the details of user. Here is my code of searchuser.jsp:
    Code:
    <% Connection connection = null;
            Statement st = null;
            ResultSet rs = null;
            Class.forName("com.mysql.jdbc.Driver");
            Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mynewdatabase","root", "root123");
         ///  st=connection.createStatement();///
               try {
            rs = st.executeQuery("Select * from user order by useid Asc");
                               while (rs.next())
                                     {
                          %>
                                    <option value = "<%=rs.getString("userid")%>" >
                                    <%=rs.getString("emailid") + " "+rs.getString("groupid")%>
                                            </option>
                          <%
                               }
    
                           }
                           finally
                           {
                               if (rs != null)
                               {
                                   rs.close();
                                   rs = null;
                               }
                               if (st != null)
                               {
                                   st.close();
                                   st = null;
                               }
    
                           }
                       %>
    but shows error at above marked line as:

    java.lang.NullPointerException
    org.apache.jsp.searchuser_jsp._jspService(searchuser_jsp.java:91)

    Well, whether it is right way to retrive data and shows to user?
    Any suggestion is highly appreciated.
    Thanks and Regards
    Haresh
     
    Last edited by a moderator: Jul 10, 2008

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice