Shadab Alam

Greenhorn
+ Follow
since Mar 07, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Shadab Alam

Thanks for reply. Sorry I joined JavaRanch today, so I was not aware of the rules.

My model class is in "D:\MyProjects\beerV1\src\com\example\model" directory
and the Servlet is in "D:\MyProjects\beerV1\src\com\example\web" directory.
My current working directory on Windows command prompt is "D:\MyProjects\beerV1".

To compile the model class I typed on the command prompt
javac -d classes src\com\example\model\BeerExpert.java

The class is compiled but I got the warnings that I mentioned in the first post.

Now to compile the servlet, from the current working directory, i.e "D:\MyProjects\beerV1" I type the following on the command prompt
javac -classpath C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar;classes:. -d classes src\com\example\web\BeerSelect.java

And I got the errors that I wrote in my first post. Please help
14 years ago

Hii friends I m new to the Servlet world. I am going through the Head First Servlet book and facing difficulty in Chapter 3 while making the Beer Expert web app.

I need to compile the model class -

package com.example.model;
import java.util.*;

public class BeerExpert{
public List getBrands(String color){
List brands=new ArrayList();
if(color.equals("amber")){
brands.add("Jack Amber");
brands.add("Red Moose");
}
else{
brands.add("Jail Pale Ale");
brands.add("Gout Stout");
}
return(brands);
}
}


When I compile the above class on Windows the command prompt says -

"Note: src\com\example\model\BeerExpert.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details."

However the class is compiled. After that the book says me to compile Servlet version 2 -

package com.example.web;

import com.example.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class BeerSelect extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{

String c=request.getParameter("color");
BeerExpert be=new BeerExpert();
List result=be.getBrands(c);

response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("Beer Selection Advice<br>");

Iterator it=result.iterator();

while(it.hasNext()){
out.println("<br>try: " +it.next());
}

}
}


When I compile the Servlet Vertion two the command prompt gives three errors-

src\com\example\web\BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
src\com\example\web\BeerSelect.java:13: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be=new BeerExpert();
^
src\com\example\web\BeerSelect.java:13: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be=new BeerExpert();
^
3 errors


Please help me out
14 years ago
Hii friends I m new to the Servlet world. I am going through the Head First Servlet book and facing difficulty in Chapter 3 while making the Beer Expert web app.

I need to compile the model class -




When I compile the above class on Windows the command prompt says -

"Note: src\com\example\model\BeerExpert.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details."

However the class is compiled. After that the book says me to compile Servlet version 2 -




When I compile the Servlet Vertion two the command prompt gives three errors-

src\com\example\web\BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
src\com\example\web\BeerSelect.java:13: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be=new BeerExpert();
^
src\com\example\web\BeerSelect.java:13: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be=new BeerExpert();
^
3 errors


Please help me out
14 years ago