• Post Reply Bookmark Topic Watch Topic
  • New Topic

compilation error  RSS feed

 
Monica Kapoor
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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!