Where is javax.servlet?

I have jdk1.6.0_13 installed, but when I try to find the javax.servlet package or press Ctrl + Space in Eclipse after Servlet , I can’t get anything. Where can I download this package and why is it not included in the standard distribution for developers?

+49
java servlets
May 13, '09 at 19:45
source share
6 answers

javax.servlet is a package that is part of Java EE (Java Enterprise Edition). You have a JDK for Java SE (Java Standard Edition).

You can use the Java EE SDK , for example.

Alternatively, you can also use simple servlet containers, such as Apache Tomcat (see servlet-api.jar ).

+81
May 13 '09 at 19:49
source share

A little more detailed answer to the question of Joachim Sauer:

In Ubuntu, at least the tomcat6 meta- tomcat6 depends on the tomcat6 tomcat6-common (and others) libtomcat6-java package, which depends on the libservlet2.5-java package, which depends on the libservlet2.5-java (and others) package. It contains, among other things, the /usr/share/java/servlet-api-2.5.jar and /usr/share/java/jsp-api-2.1.jar , which you need servlet and JSP libraries. Therefore, if you installed Tomcat 6 through apt-get or Ubuntu Software Center, you already have libraries; all that remains is to force Tomcat to use them in your project.

Place the /usr/share/java/servlet-api-2.5.jar and /usr/share/java/jsp-api-2.1.jar libraries in the class path as follows:

  • For all projects, setting up Eclipse by choosing Window β†’ Settings β†’ Java β†’ Installed JREs, then select the JRE you are using by clicking "Edit", then click "Add External JARs" and then selecting files from the above locations.

  • For just one project, right-click on the project in Project Explorer, then select Properties β†’ Java Build Path, and then click Add External JARs, and then selecting files from the locations above.

Note 1: These are the correct versions of these libraries for use with Tomcat 6; for other versions of Tomcat, see the table at http://tomcat.apache.org/whichversion.html , although I would suggest that each version of Tomcat includes versions of these libraries that are suitable for it.

Note 2 further: libservlet2.5-java package description ( dpkg-query -s libservlet2.5-java ) says: "Apache Tomcat implements the Sun Microsystems Java Servlet and JavaServer Pages (JSP) specifications and provides a" pure Java "HTTP server An environment for running Java code: This package contains the Java Servlet and the JSP library.

+19
Feb 21 2018-12-21T00:
source share

Have you installed J2EE ? If you installed only standard (J2SE), it will not find.

+7
May 13 '09 at 19:48
source share

The usual procedure with Eclipse and Java EE web applications is to install a servlet container (Tomcat, Jetty, etc.) or an application server (Glassfish (which comes with Sun Java EE download), JBoss AS, WebSphere, Weblogic, etc. .d.) and integrate it into Eclipse using the built-in plugin in the Servers view.

When creating the wizard for a new dynamic web project, you can select an integrated server from the list. If you have an existing Dynamic Web Project without a server or want to change it, you need to change it in the "Target Rules" section of the project properties.

In any case, Eclipse will automatically place the necessary server libraries in the classpath of the project (build path).

You should absolutely not extract and copy server libraries to /WEB-INF/lib or even worse than JRE/lib yourself in order to β€œfix” compilation errors in Eclipse. This would make your network binding tied to a specific server and thus completely non-portable.

+3
May 24 '10 at 15:07
source share

If you have Java EE JDK with Glassfish, this is in glassfish3 / glassfish / modules / javax.servlet-api.jar.

+2
Oct 10 '13 at 7:05
source share

these classes are usually part of servlet.jar
http://www.java2s.com/Code/Jar/wsit/Downloadservletjar.htm

0
May 13, '09 at 20:42
source share



All Articles