• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need Help

 
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
reply
    Bookmark Topic Watch Topic
  • New Topic