0

I have a Client-Server (Client and server are seperate projects in eclipse) system setup in Eclipse(Mars) I now need to create a servlet in a new package on the client project.

when I am creating a class and trying to extend HttpServlet to it I am getting an error saying javax.servlet cannot be resolved.

When I am trying File->New->Servlet I am being able to create a new Project altogether but unable to create a servlet in the existing project.

How should I resolve the issue?

Prashant Kumar
  • 121
  • 1
  • 1
  • 7

2 Answers2

1

You need do set up the "Java Build Path" of your project. In eclipse, right-click on you project, "Build Path / Configure Build Path"

and there, in "Libraries" tab, you need to add a server runtime, that should contain servlet-api.jar

Rémi
  • 41
  • 5
0

Servlets are the Java platform technology of choice for extending and enhancing Web servers. Servlets provide a component-based, platform-independent method for building Web-based applications

See :

So when you try to create a servlet, it should be a separate project....its a web project.

Rajesh
  • 2,135
  • 1
  • 12
  • 14