Results 1 to 7 of 7
  1. #1
    hari krishna is offline Member
    Join Date
    Oct 2010
    Posts
    7
    Rep Power
    0

    Unhappy HTTP Status 500 - java.lang.NullPointerException

    Hello Everyone,

    I have a Problem Here after I create User Registeration page using JAVA SERVLET on Eclipse (Tom CAT Server)

    I have a Problem When I Click on "REGISTER" button on the created page, displaying the error message


    --------------------------------------------------------------------------
    HTTP Status 500 -

    --------------------------------------------------------------------------------

    type Exception report

    message

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    java.lang.NullPointerException
    com.obr.books.servlets.RegisterServlet.doGet(Regis terServlet.java:42)
    com.obr.books.servlets.RegisterServlet.doPost(Regi sterServlet.java:50)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:637)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:717)


    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs.


    --------------------------------------------------------------------------------

    Apache Tomcat/6.0.29


    ANY HELP GREATLY APPRECIATED

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default

    So, what is this line?
    java.lang.NullPointerException
    com.obr.books.servlets.RegisterServlet.doGet(Regis terServlet.java:42)
    Because there's a null pointer exception there.

  3. #3
    hari krishna is offline Member
    Join Date
    Oct 2010
    Posts
    7
    Rep Power
    0

    Thumbs up HTTP Status 500 - java.lang.NullPointerException

    So This were the lines probably causing the problem ?


    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    System.out.println("RegisterServlet ---->>>doGet()");
    String type = request.getParameter("type");
    System.out.println("Selected oprtation\t:" + type);
    if (type.equalsIgnoreCase(SAVE)) {
    doSave(request, response);
    }
    else {
    System.err.println("Invalid operation");
    } }

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doGet(request, response);
    }

    If you want I would be able to post the complete Servlet for you
    :confused:

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by hari krishna View Post
    So This were the lines probably causing the problem ?
    There's no "probably" involved here since the compiler will show you the exact line(s) that are causing the problem. You may wish to let us know which line it is.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default

    You ought to post code in code tags (with square brackets).

    I had to hazard a guess (you should have told us which line is the one causing the problem), but is "type" null? Is there a field on the form called "type" and are you putting anything in it before clicking register?

  6. #6
    hari krishna is offline Member
    Join Date
    Oct 2010
    Posts
    7
    Rep Power
    0

    Smile HTTP Status 500 - java.lang.NullPointerException

    Java Code:
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    		System.out.println("RegisterServlet ---->>>doGet()");
    		String type = request.getParameter("type");
    		System.out.println("Selected oprtation\t:" + type);
    [COLOR="Navy"]Line 42[/COLOR]		[B]if (type.equalsIgnoreCase(SAVE)) {[/B]
    			doSave(request, response);
    			}
    		else {
    			System.err.println("Invalid operation");
    		}	}
    
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    [COLOR="navy"]Line 50[/COLOR]		[B]doGet(request, response);[/B]
    	}
    Sorry, For late reply, i was in University .. So here are the Error causing Lines...

    Loadz of thanks for your reply
    Last edited by hari krishna; 11-26-2010 at 10:47 AM. Reason: Miss type

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Tolls is right -- type is null. So now trace back to where you think you're initializing this variable, because it's not being initialized.

    Also, please edit your post and change your [quote] and [/quote] tags to [code] and [/code] tags.

Similar Threads

  1. HTTP Status 500(problem)
    By waqar100 in forum NetBeans
    Replies: 1
    Last Post: 06-30-2010, 11:54 AM
  2. Replies: 7
    Last Post: 11-11-2009, 08:29 PM
  3. what does this means HTTP Status 500 -
    By gissah in forum New To Java
    Replies: 0
    Last Post: 03-28-2009, 03:27 AM
  4. Http Status 404 - LoginServlet.do
    By mbalas2 in forum Java Servlet
    Replies: 4
    Last Post: 03-05-2009, 05:52 PM
  5. problem with HTTP Status 404
    By orkun in forum JavaServer Faces (JSF)
    Replies: 1
    Last Post: 02-05-2009, 09:28 PM

Posting Permissions

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