13

I am modifying behavior of a web-app(server & client) running on web-sphere. I have de-compiled the code and just need to make minor changes and redeploy the code.

For this I made a simple Java Project with Eclipse EE and loaded all the de-compiled code. I only need the *.class files which I will convert to a JAR and place them at their proper place. The thing is there is a dependency which is not being resolved javax.servlet.http.HttpServletRequest so my project is not building

How to resolve this dependency?

If this dependency cannot be resolved than my guess is I could just get the JAR file for javax.servlet.http.HttpServletRequest and add to the Project's Build Path as an external JAR.

Where can I find the JAR for javax.servlet.http.HttpServletRequest

p.s. I am new to JAVA so I don't know much about HttpServletRequest also I am using Java 1.6 JRE.

Moon
  • 19,518
  • 56
  • 138
  • 200
  • 1
    You need the servlet api. It is generally provided by your servlet container. – Sotirios Delimanolis Jun 22 '14 at 23:50
  • which in my case is Web-Sphere... so are you saying that I wil have to integrate servlet container into my Eclipse IDE. – Moon Jun 22 '14 at 23:58
  • You could, but no. Your websphere installation will have the servlet-api somewhere. Otherwise, you can get it [here](http://mvnrepository.com/artifact/javax.servlet/javax.servlet-api). – Sotirios Delimanolis Jun 23 '14 at 00:01
  • @SotiriosDelimanolis which version 3.0.1 or it doesn't matter – Moon Jun 23 '14 at 00:12
  • You can include Tomcat dependencies in Maven via the `tomcat-servlet-api` and `tomcat-jsp-api` jars. One exists for each version of Tomcat. Usually adding these with scope `provided` is sufficient. – Erica Kane Sep 29 '17 at 15:09

3 Answers3

22

A long time ago I used to manually add the servletapi.jar into my eclipse project, but that is a bad practice.

Now I just create a Dynamic Web Project, then add a server (usually Tomcat), then right click on the new project - select properties - select project facets and add the Tomcat Server as the runtime. It has the files you need. Once you hit the apply button and okay button it will resolve the missing import files.

Here is a step by step description from a similar question on SO: How do I import the javax.servlet API in my Eclipse project?

enter image description here

Community
  • 1
  • 1
James Drinkard
  • 15,342
  • 16
  • 114
  • 137
6

You'll want to add the Servlet API as a "provided" dependency. That is, you only use it to compile the code, but you don't need to package it with your web application since your web container will already contain a copy of it.

Matt
  • 637
  • 3
  • 10
2

Just Download Servlet.jar file from below link.

http://www.java2s.com/Code/Jar/s/Downloadservletapi30jar.htm

add this jar file into your project using build path in eclipse.

Durgesh Gupta
  • 175
  • 1
  • 6
  • 1
    Whilst this may theoretically answer the question, [it would be preferable](//meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Enamul Hassan Jul 25 '16 at 16:31