The Struts part in the final chapter of the book has been really covered well. I tried running the code given. Everything works fine. But the beer app in the sarting chapter ( i guess chapter 3 ) uses form.html as a page where user selects the beer The app in the final chapter tells us to use form.jsp. A JSP should be used because -
"We need to pop error message ( in case the user selects a invalid beer ). Such a error message can be popped only on JSP"
The point that i wanted to bring to your attention is -
The code for form.jsp is not at all given in the book. It gave me a lot of pain in the a**, to figure out how to code the JSP I referred Struts - Complete Reference by Schieldt. But i do agree the pain was all the worth. FYI, all ranchers add this code to the form.html file of chapter 3, and rename the file as form.jsp.
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %> < add this at the top ) <html:errors/> ( i added this just after the <BODY> tag of the file, but i guess it can be added anywhere in the file)
note - if anyone wants explanantion for the above struts tag, i will give it.
Also add this to the drop - down box's code - <OPTION>pale
When i start the server i get a exception trace, prominent messages of which are -
"element type message resources must be declared "
" the content of element type "struts-config" must match "(data sources?, form beans ?, global forwards ?, action-mappings ?)"
I have typed in the xml file as it is give in the book
PLEASE HELP ME WITH THE ABOVE TWO ISSUES
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ HANG ON - By the time i posted this on the ranch, i solved the issue 2. The solution is here for your reference -
Solution to Issue No 2 - I was using this in struts-config.xml -
<!DOCTYPE struts-cofig PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
If you see properly i missed a 'n' on the first line I corrected this but it didnt solve the problem. Did some googling and found that xml file is improper as per the stuts DTD. I am using a struts 1.2 so the second line should have a 1.2 instead of 1.0 This solves the problems in ISSUE 2 and we dont see any server spit out when we start the server.
Bert Please inlcude some directions in the book that take care of the version mismatch problem as above.Its difficult for begineers to figure out the bug, but i do agrree that the pain that i took to solve the issue was all worth.
I have uploaded the entire code on [ link here ]. You can download it and save your preicious time
Still Issue 1 needs to be sorted Please Help
Thanks in advance.
SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ] Performance is a compulsion, not a option, if my existence is to be justified.
Whe you invoke SelectBeer.do the controller is invoked. Then it will create the specified ActionForm anew (because it is configured to have request scope), attempt to populate it from the request and then run the validate() method.
The color variable is not initialised, so will be null, and validate goes on to use it to do an indexOf method call, which will give a NullPointer exception.
I'm guessing that's your error, but I've not deployed the code nor seen your stack trace. When you invoke it via form.jsp, I'm betting you have some fields that set a color request parameter, which will populate the ActionForm at the previous step.