This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
First off, Tomcat/5.5.9 with Servlet 2.4 and JSP 2.0
ok, been fighting with the init() method for a while now, search through a few forums, 3 different books, api, faqs, and I have yet to get it working. The problem is none of my <init-param> are being read. I have written the init() a dozen different ways, re-wrote my web.xml twice, and no change in my page. Right now my init() method is like this
I have tryed both init() and init(ServletConfig config), no change, tryed with and without the call to super.init() tryed getting one param, all, a few, getting parameter names, not getting parameter names, a few other things that give funny errors, and all parameters still end up being null as does the getInitParameterNames().
My current web.xml is below, its changed a few times, but as far as I can see, its correct.
At the moment, Im a loss of what to do next. Im sure after a few posts it will end up being something stupid easy that I should have seen some time ago, but I really don't know whats wrong.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
Thanks! bear Forum Bartender
Joined: Sep 11, 2005
And yes, as Bear pointed out, please provide the servlet-mapping tag. But if it is not a typo, it must be web-app and not web_app. I guess that is the problem.
Joined: Oct 10, 2005
It lacks the servlet mapping because the example I was working out of does not use any, but seems like I will be changing that shortly. As for the "_"...I made the incorrect assumption that the web.xml I copied out of (I didn't want to write the first three lines again) was correct to begin with....figured it would be something stupid like a semi-colon or similar. I�m sure I wouldn't have had to post if I wasn't working on a term paper, an ERP assessment assignment, and a surprisingly large program in something I am more familiar with....
As for the name, it has been updated, I was even told by my teacher that I would have to use a proper name, sorry about that.
I am sure you know this. But, you have to access the servlet by it's name. In your case your servlet class and name are the same (Not always the best idea). Since, you do not have any URL mapping, one really has to see how you are accessing the servlet.
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Joined: Oct 10, 2005
Im new to JSP and Servlets, so Im following a book alot, in this case the example accessed the Servlet with http://localhost:8080/example/servlet/Message and the web.xml lacked the servlet mapping. So what I was doing lacked it aswell and I accessed via the same url. If I wasn't teaching the majority of this to myself, and taught by a teacher that has been teaching the class for longer (new teacher, not perfect) I would be following the standards more.
I am working on the servlet mapping, amoung other coding practices.