File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need Help

 
Bal Sharma
Ranch Hand
Posts: 273
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Every Body:
Tomcat is running. I can execute tomcat servlet examples. They work fine. But I can not compile my simple servlet as below.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloServlet extends HTTPServlet
{
public void doGet(HTTPServletRequest req,
HTTPServletResponse res)
throws HTTPServtException, IOException
{
PrintWriter out = res.getWriter();
out.println("Hello");
}
}
I had following errors.
HelloServlet.java:2 package javax.servlet does not exit
HelloServlet.java:2 package javax.servlet.hhtp does not exit
I have set class path C:\tomcat\lib\servlet.jar. Set TOMCAT_HOME = tomcat. SET JAVA_HOME=jdk1.3. Even I copied servlet.jar file from tomcat/lib folder to tomcat\webapps\example folder. This is the place I am compiling my servlet. It did not help.
Please help me what is the problem? Thanks. BK
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Include on the command line the classpath variable.

It looks something like this:
javac -classpath d:\jars\servlet.jar;d:\jars\j2ee.jar MyClass.java

you'd of course, replace the path with the path to wherever you have servlet.jar
 
Dharmesh Chheda
Ranch Hand
Posts: 204
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Bal
you have not mentioned the specific error you getting but still when i say your code i noticed that you have written
public void doGet(HTTPServletRequest req, HTTPServletResponse res)throws HTTPServtException, IOException
which infact should be
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws HttpServtException, IOException
the HTTP should be Http
replace it and check it out

------------------
IBM Certified WebSphere Application Server V3.5 Specialist
 
Bal Sharma
Ranch Hand
Posts: 273
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Dharmesh:
THANKS THOUGH FOR YOUR RESPONSE. IT IS NOT WORKING. I FIXED AS YOU INDICATED. IF THAT WAS A PROBLEM I SHOULD HAVE GOT CLASS NOT FOUND EXCEPTION ERROR.
I AM GETTING FOLLOWING ERROR. I AM TRYING THIS SINCE LAST MONDAY.
HelloServlet.java:2: package javax.servlet does not esit
import javax.servlet.*;
HelloServlet.java:3: package javax.servlet.hhtp does not esit
import javax.servlet.http.*;
HelloServlet.java:5: cannot resolve symbol
symbol : class HTTPServlet
locatio: class HelloServlet
public class HelloServlet extends HTTPServket
HelloServlet.java:7: cannot resolve symbol
symbol : class HTTPServletRequest
locatio: class HelloServlet
public void doGet(HTTPServletRequest req, HTTPServletResponse res)
FUNNY THING IS TOMCAT IS RUNNING. TOMCAT EXAMPLES ARE WORKING FINE. IF I AM NOT MISTAKEN, ONCE I USE TOMCAT FOR SERVLET "package javax.servlet and package javax.servlet.hTtp" SHOULD BE INCLUDED "C:\tomcat\lib\servlet.jar" files RIGHT! WHY IT IS NOT RECOGNIZING.
IF ANYONE HAVE BEEN BEEN BEFORE IN THIS PROBLEM PLEASE LET ME KNOW HOW TO FIX IT. THANKS GUYS. BK
Originally posted by Dharmesh Chheda:
Hey Bal
you have not mentioned the specific error you getting but still when i say your code i noticed that you have written
public void doGet(HTTPServletRequest req, HTTPServletResponse res)throws HTTPServtException, IOException
which infact should be
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws HttpServtException, IOException
the HTTP should be Http
replace it and check it out

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic