I am trying to work out the this code from HFSJ book,I am using eclipse and both my servlet as well as the person class are in package com.example.servlets
I have put the person1.jsp in WebContent folder( WebContent folder being present by default and both WEB-INF and META-INF are present in this folder itself) of the project.When I try to run the person1.jsp it gives an HTTP Status 500 error on line Person is <%= p.getName()%>. Also when I try executing the same person1.jsp after pasting it in com.example.servlets package it gave an HTTP Status 404 error.
I guess I am missing on a very basic concept.Please help and kindly explain the cause of error.
Did you go through the servlet to access the jsp, or did you access the jsp directly from the url ? If you access person1.jsp from the url, you'll probably get a NullPointerException because there will be no Person instance in the request.
Also, you only have a doPost in your servlet. Are you sure you don't want to use a doGet too ? If you don't, you'll need another jsp file to submit a POST request to the server.
Thanks for the reply,I am actually accessing the jsp from URL and its true that it is giving NullPointerException. Please explain me what corrections do I need to make so as to make my jsp up and running.