java.lang.InstantiationException
This basically means simple expressions of vanilla java that the following construction
import homework10.Reservation; // ... Reservation reservation = new Reservation();
failed.
There are many possible reasons for this:
- The class is missing from the execution path.
- Class definition could not be found.
- The class is not public.
- The class does not have a public default constructor.
- The code in the public default constructor made an exception.
Based on the code provided so far, and assuming that you are 100% sure that using a code that you think works, could be cause # 1 or # 2. This class is publicly available and has an open default constructor that does virtually nothing. So # 3, # 4 and # 5 can be scratched.
To fix possible cause # 1, make sure the class file is present in the webapp deployment in the path
/WEB-INF/classes/homework10/Reservation.class . To fix possible reason # 2, you also need to make sure the class is compiled correctly while maintaining the package structure. That way, when you are not using an IDE, such as Eclipse, but you run a low level on the command line, you must make sure that you include the package when compiling the class.
Regarding the possible solutions you found,
and most people seem to recommend using class = "..." instead of type = "..."
It is right. To find out more, open this answer: javax.servlet.ServletException: bean [name] not found within scope However this is clearly not the reason in your particular since this did not seem to solve the problem.
or using the import statement
This does not make full sense. These people get confused with the scripts. They should be avoided to any degree. <jsp:useBean> too, actually, but that's a different story. See also our Servlets widget page for some tips.
source share