• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Close, but no cigar!

 
Carol Murphy
village idiot
Bartender
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Kristin Stromberg
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).

!nuf evaH
 
Marilyn de Queiroz
Sheriff
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.coderanch.com/t/4514/Cattle-Drive/value-attribute-Reverse-Servlet
I can't seem to find the conversation I was searching for regarding this issue. Sorry. Your problem is, however, related to the way you surround your values in the jsp page.
 
Carol Murphy
village idiot
Bartender
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Carol Murphy
village idiot
Bartender
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tom Henner
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Tom
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic