Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compiling Servlet Example in HF Servlets & JSP

 
Fola Fadairo
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to convert the servlet example in the first chapter of the Head First Servlets and JSP book. I have sucessfully installed Tomcat 5.0.30. My path variable is set to
"
D:\Sun\jwsdp-1.6\jwsdp-shared\bin;D:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\;D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\Bin;D:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\;D:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\bin\prerelease;D:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\bin;D:\Qt\3.2.1NonCommercial\bin;D:\tomcat\bin;D:\tomcat\common\lib\servlet-api.jar"
I have tried setting the classpath in the environment variable instead of using the command line option, but nothing seems to work.
Has anyone ever had a similar experience or can anyone profer a solution?
Thanks in advance
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"kamfbd",

There aren't may rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One directory that appears to be missing is the current directory "."

You haven't told us why it isn't working, but omitting both the current directory and the directory starting your package means you code will never be found to be compiled.

... and welcome to the Ranch (please change your display name)

Dave
 
Fola Fadairo
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response,

First of all,here is the code

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

public class Ch1Servlet extends HtppServlet {

public void doGet(HtppServletRequest request, HtppServletResponse 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>" );
}
}

the problem lies within the import statements. I get the error messages,

cannot find symbol: symbol class HttpServlet

cannot find symbol: symbol class HttpServletRequest

cannot find symbol: symbol class HttpServletResponse

... my compilation command reads

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

I tried c:\jspfiles\project1> javac -classpath .;c:\tomcat\common\lib\servlet-api.jar -d classes src\Ch1Servlet.java

after reading your comments, but it changes nothing. I also tried c:\jspfiles\project1> javac -classpath .;c:\tomcat\common\lib\servlet-api.jar;c:\java\jdk1.5.0_05\lib\tools.jar -d classes src\Ch1Servlet.java

I still get 3 errors.

I would appreciate all help.
Thanks
Fola
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Fola", please read Bear's request more closely regarding the display name:

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

First name, a space, then you last name please.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So your code has "HtppServlet" and the error message says "HttpServlet"? Did you actually copy and paste the code and the error messages, or did you type it in? Because what's in your message can't be what's actually happening.
 
Fola Fadairo
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thx 4 ur all answers, located the problem after a whole weekend ... Http instead of Htpp :-(
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic