Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes Head First BeerSelect problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Head First BeerSelect problems" Watch "Head First BeerSelect problems" New topic
Author

Head First BeerSelect problems

robert dodson
Greenhorn

Joined: Mar 23, 2012
Posts: 8
Hello this is my first post so if I mess up please correct me; I am here to learn. A little back story I am a student. I have passed XHTML with css (Head First book) but my Java is very limited, one class using the alice software
and the current semester we are using the Head First Java and the Head First Servlet/JSP books simultaneously and all our work has been done in either Eclipse or Netbeans and we installed Tomcat 7.0 and jdk7
when I point the browser(not the internal eclipse one) at localhost:8080/Beer-v1form.html when I click the submit I get a 404 The requested resource (/Beer-v1/SelectBeer.do) is not available. before I posted I went through your classpath and moosegreeting tutorials I got it to compile and run. I should note that I tried to run my program with all the files just in eclipse but it couldn't find anything so I built the file structure in tomcat the book says and copied the files to there now I get the the previously mentioned 404. I feel more comfortable with Eclipse and have never used command line for much but I am willing to learn the right way to do this I get the impression that what the instructor is having us do is not a best practice














apache logfile
I found it but I don't know which log would help
Piyush Mangal
Ranch Hand

Joined: Jan 22, 2007
Posts: 196

First of all, You should be accessing the application using http://localhost:8080/[context-path]/SelectBeer.do and secondly the package mentioned in the web.xml does not match the package defined in the BeerSelect.java.





robert dodson
Greenhorn

Joined: Mar 23, 2012
Posts: 8
Piyush Mangal thank you for your input I see the package problem and have taken a closer look at the directions in the text I made these changes(code below) I made separate packages for BeerSelect and BeerExpert to match what the book says. I am confused about the access statement you made I thought I understood the Head First book to say I use http://localhost:8080/beer-v1/form.html and when you click submit, the BeerSelect servlet is called and passed the user selection and then it calls the BeerExpert which returns the results which are passed to the jsp to make the reply with the results is that not right?







Piyush Mangal
Ranch Hand

Joined: Jan 22, 2007
Posts: 196
Hi,

Could you please let me know where is your form.html located in war and what is the context-path? As for access statement, normally htmls and jsps are stored in WEB-INF folder so that they can be protected from direct access, I guess that is not the case here.
robert dodson
Greenhorn

Joined: Mar 23, 2012
Posts: 8
this is my file structure I have seen a few references to a war but I don't know what that is.

just to be thorough here are my environmental variables

PATH C:\Program Files\Java\jdk1.7.0_03\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\

JAVA_HOME C:\Program Files\Java\jdk1.7.0_03

CLASSPATH C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin

I am not sure CLASSPATH is right
Piyush Mangal
Ranch Hand

Joined: Jan 22, 2007
Posts: 196
Folder structure looks fine to me. You don't need to set the CLASSPATH variable.
Did you recompile the BeerSelect.java after changing the package declaration?
What is the output when you access http://localhost:8080/Beer-v1/SelectBeer.do directly?
robert dodson
Greenhorn

Joined: Mar 23, 2012
Posts: 8
WOOO HOOOO its working I changed the packages and recompiled and restarted tomcat and it all works. I did try to go to http://localhost:8080/Beer-v1/SelectBeer.do directly like you asked and I got HTTP method GET is not supported by this URL but the Beer-v1/form.html serves up the right pages and when you submit the jsp serves up the answer thank you for your help
 
 
subject: Head First BeerSelect problems