This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I am using the book Head First Servlets and JSP to get up and running on J2EE concepts.
I had successfully managed to run the version 1 of the Beer Application after deployment.
Version 2 involves testing and building the model class and modifying the BeerSelect.java servlet to tie it up with the model (pages 82-85 of the Indian subcontinent edition of the book)
I'm following the instructions exactly as given in the book and I'm also using an identical directory structure as recommended in the book for both my development and deployment environment.
My Development Enivronment is in the directory : C:\MyMVCProjects\BeerV1 I've placed my BeerExpert.java file in this directory : C:\MyMVCProjects\BeerV1\src\com\example\model After compilation, the class file for BeerExpert.java has been placed in this directory :C:\MyMVCProjects\BeerV1\classes\com\example\model Version 1 of the BeerSelect.java servlet is placed in this directory : C:\MyMVCProjects\BeerV1\src\com\example\web After compilation, the class file of version 1 of the BeerSelect.java servlet has been placed in this directory : C:\MyMVCProjects\BeerV1\classes\com\example\web
However, when I make changes to the version 1 servlet code to incorporate the usage of the model (i.e version 2 of the servlet), it doesn't compile. I have checked the code several times, and I can't see any errors with it as it is a carbon copy of what's in the book.
Can anyone please help me out of this? Thanks in advance.
Sridhar Venkataraman
Ranch Hand
Joined: May 22, 2006
Posts: 76
posted
0
This is the code for version 2 of the servlet (BeerSelect.java), if it helps (it is identical to the code in the book). BeerExpert.java (the model class) compiled successfully as I have mentioned in my earlier post.
response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("Beer Selection Advice <br>"); String c = request.getParameter("color"); out.println("<br> Got beer color" + c);
BeerExpert be = new BeerExpert(); List result = be.getBrands(c); Iterator it = result.iterator(); while(it.hasNext()) { out.print("<br> try : " + it.next()); } } }
Sridhar Venkataraman
Ranch Hand
Joined: May 22, 2006
Posts: 76
posted
0
I've fixed the error myself, after some banging-head-on-table moments. It was something to do with the CLASSPATH again. My bad.
In recent days, there have been a large number of "I can't compile servlets" posts that have been moved to the Java in General (beginner) forum where learning how to compile Java classes is discussed.
Rather than add this topic to that list, I'm going to close this and refer you to that forum where you will find previous topics that cover this subject.