GeeCON Prague 2014*
The moose likes Servlets and the fly likes compiling Servlet Example in HF Servlets & JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "compiling Servlet Example in HF Servlets & JSP" Watch "compiling Servlet Example in HF Servlets & JSP" New topic
Author

compiling Servlet Example in HF Servlets & JSP

Fola Fadairo
Ranch Hand

Joined: Feb 16, 2004
Posts: 35
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

Joined: Jan 10, 2002
Posts: 61310
    
  66

"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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Feb 16, 2004
Posts: 35
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

Joined: Mar 06, 2001
Posts: 13459

"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
Marshal

Joined: Mar 22, 2005
Posts: 42035
    
  64
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.


Ping & DNS - my free Android networking tools app
Fola Fadairo
Ranch Hand

Joined: Feb 16, 2004
Posts: 35
thx 4 ur all answers, located the problem after a whole weekend ... Http instead of Htpp :-(
 
GeeCON Prague 2014
 
subject: compiling Servlet Example in HF Servlets & JSP