• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

compilation error

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,
I have a problem, for your info. it from chapter 3 of Head first Servlets and Jsp. I have this Servlet code below and the Model code also below.I have imported the model package in line 2 of servlet code, but when I compile it in Windows XP it says model package does not exit and gives the error message as shown below.Please help.I am a beginner.
Monica


Servlet Code:

package com.example.web;
import com.example.model.*; --- Here I am importing the Package of Model
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

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 Selectio 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());
}
}
}


Error Message:


C:\Documents and Settings\Monica\Desktop\MyProjects\beerV1\src\com\exampl
e\web>javac BeerSelect.java
BeerSelect.java:2: package com.example.model does not exist
import com.example.model.*;
^
BeerSelect.java:17: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
BeerSelect.java:17: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
BeerSelect.java:19: cannot find symbol
symbol : method Iterator()
location: interface java.util.List
Iterator it = result.Iterator();
^
4 errors

C:\Documents and Settings\Monica\Desktop\MyProjects\beerV1\src\com\exampl
e\web>
[ February 04, 2006: Message edited by: Bear Bibeault ]
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a servlets question. Moved to Java in General (beginner) with an appropriate change of title.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try compiling with a classpath so that the package can be found. For example, if the location is c:\myJava\com\example\model, then try compiling with...

javac -classpath c:\myJava BeerSelect.java
 
Your mother was a hamster and your father was a tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic