0

I am not using maven to build my project and i require the session variable that why i need servlet-api.jar file in the build path . But when i am configuring using it maven its throwing me the error

servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

the code for session variable

(session.getAttribute("surveyDesc")

just because stackoverflow was not allowing me to post the question else .

abhishek
  • 149
  • 12
  • you need servlet-api.jar file at your class path, because of absent it, you are getting error while work with session..., please provide servlet-api.jar at your class path. – Vishal Gajera Apr 18 '16 at 14:02
  • when i am adding it it's throwing me this error servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class – abhishek Apr 18 '16 at 14:03
  • right now where did you placed servlet-xx.jar into your application, is it into "web-inf/lib" ? – Vishal Gajera Apr 18 '16 at 14:07
  • If you're not using maven, how do you build your project? As can be found in several [other questions](http://stackoverflow.com/questions/1993493/error-servlet-jar-not-loaded-offending-class-javax-servlet-servlet-class) this may be related to whatever build system you're using trying to deploy the servlet-api.jar file. That file should be available at compiletime, but not distributed as that will cause the conflict you're seeing. – fvu Apr 18 '16 at 14:10

1 Answers1

0

Try this dependency and check it should work.

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
</dependency>
soorapadman
  • 4,451
  • 7
  • 35
  • 47
  • i am not using maven – abhishek Apr 18 '16 at 14:03
  • @abhishek oops i think you should look at this link it will resolve your issue:http://stackoverflow.com/questions/15601469/jar-not-loaded-see-servlet-spec-2-3-section-9-7-2-offending-class-javax-serv – soorapadman Apr 18 '16 at 14:07