Results 1 to 2 of 2
  1. #1
    Viruthagiri is offline Member
    Join Date
    Mar 2010
    Posts
    2
    Rep Power
    0

    Default Please solve my error occured java.lang.NullPointerException

    This is my code: I figured out the else part of the code causing this error. But i don't understand what is that. Can anyone solve this. Any kind of help suggestion will be appreciated. Thanks
    Java Code:
    <%@ page import="INCLUDES.DBConnection"%>
    <%@ page import="java.sql.*"%>
    <%@ page import="java.io.*"%>
    <jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
    <jsp:setProperty name="DB" property="*"/>
    <%
    	String user_name=request.getParameter("user_name");
    	ResultSet objRs=null;
    	String statement="";
    	try
    	{
    		statement="select * from x_master_elearning_user where user_name='" +
     user_name + "'";
    		DB.setStatement(statement);
    		objRs=(ResultSet)DB.resultUpdate();
    		
    		if(objRs.next())
    		{
    			response.sendRedirect("signup.jsp");
    		}
    		else
    		{
    			objRs.updateString("user_name",user_name);
    			objRs.updateString("pass_word",request.getParameter("pass_word"));
    			objRs.updateString("first_name",request.getParameter("trainee_name"));
    			objRs.updateString("designation",request.getParameter("designation"));
    			objRs.updateString("email",request.getParameter("email"));
    			objRs.updateString("city",request.getParameter("city"));
    			objRs.updateString("country",request.getParameter("country"));
    			objRs.insertRow();
    			response.sendRedirect("course_list_index2.jsp");
    		}
    		
    	}
    	catch(Exception e)
    	{	
    	        out.print("error occured " + e);
    	}
    %>

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    That code is very bad.

    Write a normal Java class to retrieve the data you want to display.
    Call that class' methods from a servlet.
    Set the results into request scope and pass control to the JSP.
    Retrieve the request scoped attributes and display them on the JSP using el.

Similar Threads

  1. java.lang.NullPointerException Error
    By Manfizy in forum NetBeans
    Replies: 3
    Last Post: 02-24-2011, 06:27 AM
  2. Replies: 4
    Last Post: 04-23-2010, 01:54 PM
  3. Please solve my java.lang.NullPointerException error.?
    By Viruthagiri in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-23-2010, 09:30 PM
  4. Replies: 1
    Last Post: 12-05-2009, 07:28 AM
  5. Replies: 2
    Last Post: 07-02-2007, 02:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •