Bear Bibeault wrote:Is this something you want to do on the client with JavaScript, or wait until the form is submitted and check it n the server? (or both?)
Bear Bibeault wrote:OK, so perform the check within the servlet code, and if it fails, redirect back to the page with information that the validation failed. The session would be a good place to store message info (be sure to clean it out when done) if you'd rather not tack it onto the URL itself.
john krem wrote:With regards to your ps, I do not know as I am only in my 3rd week of learning servlets, so I think JSPs are coming soon.
Bear Bibeault wrote:What exactly are you getting back as results if not an empty array?
Bear Bibeault wrote:
john krem wrote:With regards to your ps, I do not know as I am only in my 3rd week of learning servlets, so I think JSPs are coming soon.
Ah, OK. You will discover (hopefully) that emitting HTML from a servlet is an anti-pattern to be generally avoided. But as you are just learning for now...
Bear Bibeault wrote:I don't see where your check is happening in the grands scheme of things. Is there some conditional that's preventing the check from happening under certain circumstances?
Bear Bibeault wrote:Why not show the code at this point?
Also, for debugging purposes, I'd recommend printing ut the length of the array rather than doing an "if". That way, you don;t have to try and guess whether the code was executed or not.
Bear Bibeault wrote:Hint: use proper indentation. It'll make you code easier to read.
Change the debug statement to print the length without any conditional. What does it print?
Just print out the length of the array withut testing it. What does it say?john krem wrote:I'm not sure what you mean by withouy any conditional
This seems to imply that it is working elsewhere?so I'm not sure why it's not working in the servlet.
processRequest() is not a standard method of a servlet so I'd have no way of knowing. I assume it's a method you are calling from one of doPost() or doGet()?I have everything in the processRequest() in the servlet, could that have anything to do with it?
Bear Bibeault wrote:Have you checked the logs for exceptions?
Bear Bibeault wrote:OK, then you now know that items will be null, rather than an enpty array, when no items are selected. So that is what you'll need to test for,