I downloaded Eclipse Java EE IDE to build Java Web Applications (servlets and JSP pages). But it still is not supporting the javax.servlet
package.
Why? What's the reason? Is there any plugin that I need to install?
You need to integrate a servlet container in Eclipse and associate it with your Dynamic Web Project. Eclipse doesn't ship with a servlet container by default. You need to download and install it separately. A widely used one is Apache Tomcat. Just download the ZIP and extract it somewhere.
Then in Eclipse, go to the Servers view in the box at the right bottom. Then Add a new server where in you choose Apache Tomcat 6 from the list and point the Tomcat root folder (there where you extracted it). Then you can select it from the Target Runtime dropdown during the Dynamic Web Project creation wizard. Or if you already have created one but didn't associate it with a server, then modify it in the Targeted Runtimes section of the project's properties. This way the server's libraries will be automagically added to the project's buildpath. That's finally also the whole point. The server is basically a concrete implementation of the abstract Servlet API. It has all the API libraries in its /lib
folder.
Here's a video tutorial (which does it a bit differently than above described, but it's also sufficient) and here's a text/screenshot tutorial (you can just skip the JSF part if that's not of interest yet).
You probably need to create a Dynamic Web Project instead of a normal Java project.
Or you can add a server profile to your workspace, and then add the server runtime to a Java project's libraries.
Window -> Preferences -> Server -> Runtime Environments
. Click Add...
, choose the server type that you're using, specify the directory where that server is installed, and click Finish
.Properties -> Java Build Path -> Libraries -> Add Library -> Server Runtime
, choose the server you just added from the list, and click Finish
. This will make all the server's libraries available to your project.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With