Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javax.servlet.* cannot be resolved to a type

I am running ubuntu 14.04 and eclipse Kepler (with java ee modules preloaded) , I am developing Dynamic Web App for first time, it always says javax.servlet.xyz cannot be resolved to a type please help I am including a screen snapshot for my error page!

System Snapshot

like image 639
Chinmaya B Avatar asked Jun 27 '14 16:06

Chinmaya B


People also ask

Where is javax servlet package?

It contains, among others, the files /usr/share/java/servlet-api-2.5. jar and /usr/share/java/jsp-api-2.1. jar , which are the servlet and JSP libraries you need.

What is Servlet in advanced Java?

A servlet is a Java programming language class that is used to extend the capabilities of servers that host applications accessed by means of a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by web servers.


1 Answers

Only two things are required in Eclipse for this:

One

In Eclipse, Window -> Preferences -> Server -> Runtime Environment
Specify your Web Server or Application Server path, by adding a "New Server Runtime Environment".

Update

Initially, there are only few Server Runtime Environments available with Eclipse like:

  1. Apache
  2. Basic
  3. ObjectWeb

On an additional note, you can add more Server Adapters using the link Download additional server adapters in Server Runtime Environments dialog screen.

Server Runtime ENvironment List in Eclipse Preferences

Two

In Project Properties (Right Click on Project -> Properties), in Java Build Path, add Library "Server Runtime".
On adding Server Runtime to Project Library will add servlet-api.jar and jsp-api.jar jars to project dependencies.

Add Server Runtime Library to Project

like image 175
Mandar Pandit Avatar answered Oct 06 '22 00:10

Mandar Pandit