Saturday, April 19, 2014

Learning - Servlets with Cookies (in NetBeans IDE)



Hey Expert! (if you're not already, you will be!)

I'm not sure if anyone else has seen this issue, but I was going through one of the Hands-On tutorials (using PC) and pressed Alt+Enter to search for classes to import (since Ctrl+Shift+I was not triggering the Import). The dialog opened a set of libraries to choose from. Does it matter which javax.servlet.* to use (version?, etc.)? I'll go back through and double check my dependencies, but just thought I would ask


When I manually add the imported Class, remove the import, and declare the Cookie object, then I see the option to auto-import http.Cookie class. Any ideas on this behavior with NetBeans IDE?

<<I still need to research this behavior in NetBeans IDE.>>

However, I did get an answer from my professor regarding how the library we use in our Servlet does matter. Here's what he says:

Yes, it does matter.  You want to make sure that we pick up Servlet 3.1. If you select javax: javaee-web-api 7.0, you will get *all* Java EE 7 (Web Profile) APIs, and not just servlet 3.1. As an FYI, this jar file does not contain implementation of the Java EE 7 APIs, it contains enough of the API to compile against. The implementation of the APIs is the application server itself, and in this course that means GlassFish 4.0.

So, I use (import) the library:  javax.servlet-api (3.1.0) JAR.

No comments:

Post a Comment