Tenho um erro aqui e nao encontro a solucao:
C:\WebProjects\MyProjects\beerV1>javac -classpath \tomcat\common\lib\servlet-api
.jar -d classes 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:20: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
src\com\example\web\BeerSelect.java:20: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
3 errors
O codigo do servlet e:
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{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Beer Selection Advice<br>");
String c = request.getParameter("color");
BeerExpert be = new BeerExpert();
List result = be.getBrands(c);
Iterator it = result.iterator();
while(it.hasNext()){
out.print("<br>try: " + it.next());
}
tambem foi criado o codigo da classe ‘model’ que e:
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);
}
}
e tambem o arquivo .xml. quando compilo aparece este erro,pois nao encontra a package com.example.model que eu ja criei.
O meu ambiente de desenvolvimento e:
c:\webprojects\myprojects\beerV1\etc\web.xml
c:\webprojects\myprojects\beerV1\lib
c:\webprojects\myprojects\beerV1\src\com\example\web\Beerselect.java
c:\webprojects\myprojects\beerV1\src\com\example\model\BeerExpert.java
c:\webprojects\myprojects\beerV1\classes\com\example\web\Beerselect.class–> nao gera esta classe neste diretorio
c:\webprojects\myprojects\beerV1\classes\com\example\model\BeerExpert.class–> nao gera esta classe neste diretorio
alguma sugestao por favor?