943,793 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 18434
  • Java RSS
Jun 29th, 2008
0

Is "javax.servlet" included in Eclipse SDK

Expand Post »
I'm trying to learn Java Servlets on my own but I'm having some very basic problems.

The code
Java Syntax (Toggle Plain Text)
  1. "import javax.servlet.ServletException;"
produces a compiler error, "the import javax.servlet cannot be resolved".

I'm using version 3.2.2. Why am I having this problem?
Reputation Points: 11
Solved Threads: 1
Junior Poster in Training
knight fyre is offline Offline
88 posts
since Feb 2008
Jun 29th, 2008
0

Re: Is "javax.servlet" included in Eclipse SDK

Nope by default the Java Plugin for Eclipse only includes Core Java, Servlets are not a part of that.
A short cut to resolve that error would be, in case you have tomcat / some other java enabled server installed, just check in their "lib" folder if you find any jar called "servlet.jar" or "j2ee.jar" or something similar in name and add it to your project's build path in Eclipse, this should solve the compile error.

However you will not be able to test your servlets directly via Eclipse in this case
Last edited by stephen84s; Jun 29th, 2008 at 6:45 am.
Featured Poster
Reputation Points: 653
Solved Threads: 151
Nearly a Posting Virtuoso
stephen84s is offline Offline
1,316 posts
since Jul 2007
Jun 30th, 2008
0

Re: Is "javax.servlet" included in Eclipse SDK

I'm using Tomcat 5.0.

There are multiple lib folders and none of the jar files match exactly. Which folder should I look into? Even if I choose the right folder how exactly should I add it the built path? I attached the search result of "lib".

What is the other method of installing the servlet package?
Attached Thumbnails
Click image for larger version

Name:	searcheresults.JPG
Views:	631
Size:	148.0 KB
ID:	6471  
Reputation Points: 11
Solved Threads: 1
Junior Poster in Training
knight fyre is offline Offline
88 posts
since Feb 2008
Jun 30th, 2008
0

Re: Is "javax.servlet" included in Eclipse SDK

if you are using the latest version of tomcat 6.0+ there is a "lib" folder in the ROOT directory of tomcat, you should find the servlet.jar file there.
In tomcat 5.0 I assume it should be in $CATALINA_HOME/share/lib The second way is to install the J2EE Standard Tools plugin for eclipse.
Last edited by stephen84s; Jun 30th, 2008 at 3:11 am.
Featured Poster
Reputation Points: 653
Solved Threads: 151
Nearly a Posting Virtuoso
stephen84s is offline Offline
1,316 posts
since Jul 2007
Jun 30th, 2008
0

Re: Is "javax.servlet" included in Eclipse SDK

I found the jar file with the packages. Problem solved.
Reputation Points: 11
Solved Threads: 1
Junior Poster in Training
knight fyre is offline Offline
88 posts
since Feb 2008
Oct 11th, 2011
-1

Servlets in Eclipse require to import javax.servlet package to be imported

javax.servlet.* package is not included in Eclipse. It is present in Tomcat 6.0/lib folder as servlet-api.jar and jsp-api.jar.
These two files can be imported to Eclipse by right clicking on your project's name in the Eclipse's Explorer window and selecting properties option from the popup menu. Then select Libraries tab from Java Build Path and then click Add External Jar option. Browse to the Tomcat installation folder and then select lib folder. Choose file servlet-api.jar and click finish.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
varun.x.anand is offline Offline
1 posts
since Oct 2011

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: getting there- please help with java
Next Thread in Java Forum Timeline: Help with a while loop





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC