[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2949
  • Last Modified:

The import javax.servlet cannot be resolved

Hi Experts,
I am shifted from .Net to Java so pls consider me.
I am using eclipse to build Dynamic web project in java.
But when I try to import the servlet namespace it is giving me error.

"The import javax.servlet cannot be resolved"

Hope that I have explained in details.Any help is appreciated.
0
johny_bravo1
Asked:
johny_bravo1
  • 5
  • 4
3 Solutions
 
objectsCommented:
you need to add the servlet api jar to your projects build path
you can reference one from your container

0
 
johny_bravo1Author Commented:
It may b the very basic questions but Can you pls tell me where is this  servlet api jar?
and what is the project build path?
0
 
objectsCommented:
> Can you pls tell me where is this  servlet api jar?

its not part or java or eclipse, so you need to get it elsewhere
as you are building a web project you will need a servlet container (eg tomcat), the container will have the required jar

> and what is the project build path?

you'll find its details by right clicking the project and selecting build path from menu
It defines what is needed to build your project

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
johny_bravo1Author Commented:
Thanks objects,that is solved.
there is one more error for beolw line
import org.apache.commons.lang.StringUtils;

Error "The import org.apache.commons cannot be resolved"
How to resolve this?
0
 
objectsCommented:
download commons lang and add its jar to your build path
http://commons.apache.org/lang/
0
 
johny_bravo1Author Commented:
Hi ,
when I added the jar error for belo line is resolved.
import org.apache.commons.lang.StringUtils;

but for these lines it didn't work
import org.apache.log4j.Logger;
import org.apache.struts.Globals;
0
 
objectsCommented:
more jars again.  for those you need log4j and struts

0
 
johny_bravo1Author Commented:
import org.apache.log4j.Logger;
import org.apache.struts.Globals;

For the above lines I m getting,
The import org.apache.log4j.Logger cannot be resolved
The import org.apache.log4j.Logger cannot be resolved

As per your comment I have included jars from
http://commons.apache.org/downloads/index.html
and Logging in it.

Is it the right place I am looking for those packages?
0
 
VenabiliCommented:
>>Is it the right place I am looking for those packages?
No, commons logging is the old way for loggings.

log4j is here: http://logging.apache.org/log4j/1.2/download.html

And struts is here http://struts.apache.org/download.cgi in case you do not have it as well.
0
 
johny_bravo1Author Commented:
Thanks Venabili.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now