I am beginner in Java EE and when I install Tomcat 7, its works fine, I can access http://localhost:8080.
Now I understood that servlet and jsp jars files come under tomcat 7 and no need to download from oracle site.
So my question is when I compile my first servlet, it’s say import javax.servlet.*; and import javax.servlet.http.*; not found.
How can I solved this?
Also one more thing In that servlet, I am also looking for visited user ip address. So I can know the location of that user.
I am using window platform and I configured JDK properly and its work fine.
hmmm, this is common question for beginner in Java EE, even I was too. Don’t worry, here I am explaining you – How to solve this problem?. Here I am assume that you know How to install and configure tomcat 7, if not, visit http://www.coreservlets.com/Apache-Tomcat-Tutorial/
Basically tomcat 7 (even old one) come with servlets and jsp jars, you can find those jar in tomcat’s lib folder
Now you need to place these files in classpath (let me know if you don’t know How to set files in classpath) By default tomcat not setting classpath for servlets.
After that if you compile your java file, it should works. let me know if you face any problem or difficulties.
if you want user location, you need to use
request.getRemoteAddr()and it will give you the ip address, regarding location name (city, state, country and even more information), please visit http://www.maxmind.com/ services.Here is the some links
http://www.maxmind.com/app/geolitecity
Example – http://geoip.cvs.sourceforge.net/viewvc/geoip/java/CityLookupTestV6.java?view=markup