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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

setting classpath

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
hi everyone,

i am new to servlet
i am reading K&B book for SCWCD.
i tried to run the program (chapter 1 ,page no 30)
but its showing 5 errors


Ch1Servlet.java:1: package javax.Servlet does not exist
import javax.Servlet.*;
^
Ch1Servlet.java:2: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
Ch1Servlet.java:5: cannot find symbol
symbol: class HttpServlet
public class Ch1Servlet extends HttpServlet
^
Ch1Servlet.java:7: cannot find symbol
symbol : class HttpServletRequest
location: class Ch1Servlet
public void goGet(HttpServletRequest request, HttpServletResponse response)
throws IOException
^
Ch1Servlet.java:7: cannot find symbol
symbol : class HttpServletResponse
location: class Ch1Servlet
public void goGet(HttpServletRequest request, HttpServletResponse response)
throws IOException

i set the classpath as said in the book.
i read some other posts regarding this probelm and tried to solve
but in vain.

please some one help
thanks in advance
thank you all
 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
If your are new to servlets, you should download and install Netbeans IDE first:
it comes with tomcat,glassfish and it's all configured.
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Include the servlet-api.jar file in your lib folder.
 
Ranch Hand
Posts: 451
1
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi,

You are missing the servlet.jar in your CLASSPATH environmental variable.

Cheers,
Raj.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please add servlet-api.jar present in your tomcats common/lib folder and add it to the classpath by using environment varables settings in your system.

Problem is tomacat is not able to find the APIs related to servlets since they are not on classpath .

Above solution will work for any web project running inside Tomcat
 
ks karthe
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
thank you everyone
now it compiled fine , but still its showing HTTP status 404 error
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
The page you are trying to access is not located. Try restarting Tomcat or check if you really have the jsp/html page that you are accessing. Look at your web.xml.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Closing duplicate
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic