Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help on the Head First book

 
Rodrigo J. Oliveira
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I just started to study to SCWCD and I am having some problems.
On page 89, in the mini MCV tutorial, when you try to do the code for servlet version three, the final one when the servlet finally uses the JSP. I can't compile it. In the book we have:
request.setAttribute("styles", result);
The compiler complains cause it cannot resolve symbol "result". Where this result comes from? it is not instanciated anywhere before.
Please, can somebody help me? All the rest I did, but I can't complete the tutorial because of it. Thanks in advance.
 
Rodrigo J. Oliveira
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ohh, another newbee question. I can't compile the servlet with the command:
javac -classpath /Users/bert/Applications2/tomcat/common/lib/servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java

the compiler runs and tells that can't find those packages:
import javax.servlet.*;
import javax.servlet.http.*;
I already put the .jar files from the Tomcat lib on the runtime enviroment on my machine wich by the way runs a Windows XP. Anyway I can't make it find the servlet packages.
It also complain that can't find the package:
import com.example.model.*;
This import is to use the model class BeerExpert.java
I am sure that my directory structure is the same as the book. The code for BeerExpert class is also exactly the same as the book, I already compiled it and tested it by making another class calling BeerExpert's method. In BeerExpert code the first line says it is on the com.example.model package. The code is exactly as in the book.

Anyway I can compile everything using the Sun One Studio, cause the Sun One makes the filesystems structure and already put the files in the classpath by itself, so everything compiles fine with the Sun One Studio.
What can I do to compile it by command?
Thanks and be mercifull with the newbee!^_^
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
About your first post, did you check the errata ?
Check it here
 
Cai DongShan
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rodrigo,

For your first post, please check lines just before the line you mentioned.

BeerExpert be = new BeerExpert();
List result = be.getBrands(c);

For your second post, you should change : to ; for Windows platform.

javac -classpath /Users/bert/Applications2/tomcat/common/lib/servlet-api.jar;classes;. -d classes src/com/example/web/BeerSelect.java
 
Rodrigo J. Oliveira
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Cai DongShan. I did as you told and it all worked out. I really had named The List object result diferent. The command also works with the ;
Everything is compiling right, but now I can't make the step 3 wich is the servlet calling the JSP. I remade it several times and can't find the error. until the step 2 everything is fine. The servlet calls the model and return the html to the browser perfectly, but I cannot make the JSP step and don't know why. The error message I get is this:

Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception

org.apache.jasper.JasperException: /result.jsp(5,17) equal symbol expected
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:90)...


and it goes on with lots of errors. I wont put everything here cause the list of errors is too long.
I looked in the log of Tomcat and it says almost the same thing:
2006-01-05 03:20:45 StandardWrapperValve[ch3 Beer]: Servlet.service() for servlet ch3 Beer threw exception
org.apache.jasper.JasperException: /result.jsp(5,17) equal symbol expected


I have tried many times, I can't find the error.
Any help would be much apreciated. Thanks!
[ January 04, 2006: Message edited by: Rodrigo J. Oliveira ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have the book, so I cannot probably help much,
but did you check line 5 of result.jsp ?

If you could post it, we might understand what the problem is.
 
Rodrigo J. Oliveira
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wow, it is 3:53 am here in Brazil and I finnaly got it working. Uffa, I was almost quitting from the idea of taking this exam.
It was a small mistake on the JSP code.
Thanks everyone!
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good luck for your studies and... good night !
 
vipul patel
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

Why don't you use Eclipse IDE, configure tomcat as web-container. Just create a project and keep adding different packages while working through the book.

It will save you admin tasks because they are not the Exam. Within IDE only, you can open a browser and see your code working on a very first attempt.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic