Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • 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

Unable to compile servlet

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I need help to compile the servlet code from HFJS

Thanks.


===================================================


I try to compile the servlet code from HFJS

This is my file structure: C:\project1
classes
src
etc

I placed Ch1Servlet in C:\project\src;




I used Tomcat 5.028 and installed in c:\program files\tomcat 5.0

The enivornment variables I set up as

classpath .;c:\j2sdk1.4.2_16\lib\tools.jar;c:\j2sdk1.4.2_16\bin;%CATALINA_HOME%\common\lib\jsp-api.jar;%CLASSPATH%

path %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\j2sdk1.4.2_16\bin;d:\

JAVA_HOME C:\j2sdk1.4.2_16
CATALINE_HOME C:\program files\tomcat 5.0



I compile the servlet from command(DOS) prompt:

C:\>javac -classpath /project1/classes/tomcat/common/lib/servlet-api.jar
-d classes src/Ch1Servlet.java



import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class Ch1Servlet extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException
{
PrintWriter out = response.getWriter();
java.util.Date today = new java.util.Date();
out.println("<html>" + "<body>" + "<h1 align=center>HF\'s Chapter1 Servlet</h1>"
+ "<br>" + today + "</body>" + "</html>");

}
}


I got 5 errors as
"package javax.servlet does not exist"
"package javax.servlet.http does not exist"
"HttpServletRequest, cannot resolve system", etc




What went wrong???
 
Sheriff
Posts: 67592
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to check the Servlets FAQ before posting questions to see if your issue has already been addressed.
[ November 12, 2007: Message edited by: Bear Bibeault ]
 
Live a little! The night is young! And we have umbrellas in our drinks! This umbrella has a 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
reply
    Bookmark Topic Watch Topic
  • New Topic