aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Help on the Head First book Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Help on the Head First book" Watch "Help on the Head First book" New topic
Author

Help on the Head First book

Rodrigo J. Oliveira
Greenhorn

Joined: Mar 09, 2005
Posts: 7
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

Joined: Mar 09, 2005
Posts: 7
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

About your first post, did you check the errata ?
Check it here


[My Blog]
All roads lead to JavaRanch
Cai DongShan
Ranch Hand

Joined: Dec 07, 2004
Posts: 102
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


Best Regards,<br />DongShan<br /> <br />SCJP1.4, SCWCD1.4
Rodrigo J. Oliveira
Greenhorn

Joined: Mar 09, 2005
Posts: 7
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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

Joined: Mar 09, 2005
Posts: 7
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

Good luck for your studies and... good night !
vipul patel
Ranch Hand

Joined: Oct 16, 2005
Posts: 146
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help on the Head First book