I thought I had Servlets 3a ready to submit, but I discovered a snag. When I enter one word in the text box, the servlet works as it should. I tried to reverse a sentence, but only the last word gets reversed and shows up in the text box. I'm not sure why this is happening, or how to fix it, but I'm working on it!
I think I encountered the same problem on this... if I remember correctly, it was simply a matter of wrapping the JSP expression in single quotes so that the whole value is displayed and not just the first word of the reversed text.
Also, don't forget that your servlet needs to be able to handle both single and double quotes in the text being reversed (this might save you a round of nitpicking).
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Joined: Mar 15, 2001
Marilyn, that is my suspicion. I just can't find any examples to show me how it should be done, or come up with a solution through trial and error (the emphasis being on error) that works. I remember going through a similar episode with the html version of this problem, but I can't find a solution that will work with JSP. Still looking!
Marilyn de Queiroz
Joined: Jul 22, 2000
I think it would look remarkably similar to the portion of the jsp page on the assignment page for Servlets 2 (Reverse):
except that you need to add a <pre>value='(put something here)'</pre> into the input tag. [ September 24, 2005: Message edited by: Marilyn de Queiroz ]
Joined: Mar 15, 2001
Yep, it was a pair of single quotes that was missing. Wierd thing is, I know I tried that earlier, but maybe it was during the missing package statement phase, and therefore it didn't work. Is writing code like that for anyone else? I mean, you write something one way, it doesn't work, you tweak something else, then go back and suddenly everything works but you're not sure which change was the one that did the trick? Makes me crazy.
Carol, It sure works that way for me. The nitpicking helps a lot. I've always just focused on input/output and making sure users can't break anything. Now I'm learning to check to see if that extra cast is necessary, if something can be cleaner, etc.