Click to See Complete Forum and Search --> : java servlet not compiling
aks01
May 3rd, 2010, 05:08 AM
i have set classpath=".;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet.jar".
and compiled servlet program on the command line as-
c:\>javac HowdyServlet.java
then also it's not working
any guesses!!
dlorde
May 3rd, 2010, 05:46 AM
Post up the full text of the error message you get. Java error messages generally tell you what the problem is.
Unless in communicating with it [a computer] one says exactly what one means, trouble is bound to result...
A. Turing
aks01
May 3rd, 2010, 05:55 AM
okay.
C:\jwork>javac Howdyservlet.java
Howdyservlet.java:3: package java.servlet.http does not exist
import java.servlet.http.*;
^
Howdyservlet.java:5: cannot find symbol
symbol: class HttpServlet
public class HowdyServlet extends HttpServlet{
^
Howdyservlet.java:6: cannot find symbol
symbol : class HttpServletRequest
location: class HowdyServlet
public void doGet(HttpServletRequest request,
^
Howdyservlet.java:7: cannot find symbol
symbol : class HttpServletResponse
location: class HowdyServlet
HttpServletResponse response)
^
ProgramThis
May 3rd, 2010, 08:31 AM
Really need more information about how you are trying to run this. Are you trying to run this within the tomcat container? Did you create the folder structure under "webapps/" yourself and place the compiled class out there? Did you create the TOMCAT_HOME and CATALINA_HOME environment variables?
ajhampson
May 3rd, 2010, 09:36 AM
This error:
C:\jwork>javac Howdyservlet.java
Howdyservlet.java:3: package java.servlet.http does not exist
import java.servlet.http.*;
^
Tells you what is wrong. HttpServlet is in package javax, not java. Change the import statement to
import javax.servlet.http.*;
If you are still getting a package not found error, try this:
c:\>javac HowdyServlet.java -cp ".;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet.jar".
and see if you get the same error. If not, there is something wrong with the way you set your classpath. If so, the jars are still not being found.
Let us know if you need more help.
aks01
May 3rd, 2010, 11:04 AM
i have posted same question on multiple forums but none of them figured it out that servlet class is in javax package.
hey senior brother thanks a lot.
this problem have consumed my whole day, i have corrected the above said statement and is working like cheeseeee on the bread.
thanks a lot for the time and the solution.
once again thanks all of you for showing kindness and ofcourse for putting your brains in my problem.
i will continue posting my problems here..
thanks.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.