Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need the JAR file for a javax.servlet.http.HttpServletRequest [duplicate]

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.

like image 413
Moon Avatar asked Jun 22 '14 23:06

Moon


2 Answers

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.

like image 33
Matt Avatar answered Sep 18 '22 11:09

Matt


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

like image 79
James Drinkard Avatar answered Sep 19 '22 11:09

James Drinkard