A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Java
»
Beginning Java
Author
compilation error of servlet
Kondapally Ashwin
Greenhorn
Joined: May 16, 2006
Posts: 25
posted
Apr 15, 2007 01:08:00
0
Hi,
I have a
java
file League.java
package s1314.model; public class League { int year; String season; String title; League(int year, String season, String title) { this.year=year; this.season=season; this.title=title; } public String getTitle() { return title; } }
And I have a
servlet
package s1314.view; import javax.servlet.http.*; import javax.servlet.*; import java.io.*; import java.util.*; import s1314.model.*; public class ListLeaguesServlet extends HttpServlet { private List leagueList = null; public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException,ServletException { leagueList.add(new League(2003,"Spring","Soccer League (Spring '03)")); leagueList.add(new League(2003,"Summer","Summer Soccer Fest 2003)")); leagueList.add(new League(2003,"Fall","Fall Soccer League 2003)")); leagueList.add(new League(2004,"Spring","Soccer League (Spring '04)")); leagueList.add(new League(2004,"Summer","The summer of Soccer Love 2004)")); leagueList.add(new League(2004,"Fall","Fall Soccer League 2004")); res.setContentType("text/html"); PrintWriter pw = res.getWriter(); pw.println("<html><head>"); pw.println("<title> list of games</title>"); pw.println("<body>"); pw.println("<ul>"); Iterator items = leagueList.iterator(); while (items.hasNext()) { League league = (League)items.next(); pw.println("<li>"+league.getTitle() +"<li>"); } pw.println("</ul>"); pw.println("</body></html>"); } }
The League class is compiled in the folder s1314\model and the servlet file is placed in the folder s1314\view.
I am getting some errors like "package s1314.model does not exist" and "cannot find symbol class 'League'".
Please advise me why I am getting such compilation errors.
Deepak Bala
Bartender
Joined: Feb 24, 2006
Posts: 6603
1
I like...
posted
Apr 15, 2007 01:37:00
0
Make sure the folders exist in your classpath
SCJP 6 articles
-
SCJP 5/6 mock exams
-
SCJP Mocks
-
SCJP 5 Mock exam (Word document )
-
SCJP 5 Mock exam in Java.Inquisition format
Kondapally Ashwin
Greenhorn
Joined: May 16, 2006
Posts: 25
posted
Apr 15, 2007 01:57:00
0
I used the command javac -classpath C:\Tomcat5.5\lib\servlet-api.jar;C:\introcs\s1314\model ListLeaguesServlet.java
But I am still getting the same error.
Please advise.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35443
9
posted
Apr 15, 2007 02:32:00
0
C:\introcs\s1314\model
The classpath must not contain the directories for packages. Use "C:\introcs" instead.
Android apps
–
ImageJ plugins
–
Java web charts
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: compilation error of servlet
Similar Threads
Strange Problem with servlet output
Problem with Packages / Utility Classes in Servlets
servlet context listener problem
unable t o compile the servlet .. plz help
unable to compile servlet
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter