hi folks,
i am a beginner in JSP, and i am studying headfirst servlet & JSP,but at the time of running a code from there,i have an problem
there is directory structure src/com/example/web/BeerSelect.java
and the code is
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.print("<br/>try: "+it.next());
}
}
}
now at the time of running this code form cmd i am getting this error
E:\JAVA\JSP\beerV1>javac -classpath D:/tomcat/common/lib/servlet-api.jar -d clas
ses src/com/example/web/BeerSelect.java
src\com\example\web\BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
src\com\example\web\BeerSelect.java:14: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be=new BeerExpert();
^
src\com\example\web\BeerSelect.java:14: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be=new BeerExpert();
^
3 errors
the path which is declred in import statement is like
src/com/example/model/BeerExpert.java
and the code for BeerExpert.java is here
package com.example.model;
import java.util.*;
public class BeerExpert
{
public List getBrands(String color)
{
List<String> brands=new ArrayList<String>();
if(color.equals("amber"))
{
brands.add("Jack Amber");
brands.add("Red Moose");
}
else
{
brands.add("Jail Pale Ale");
brands.add("Gout Stout");
}
return(brands);
}
}
i have already set the classpath and path variable,it is verymuch helpful for me ,if anyone tell me where the problem is???