File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Cattle Drive and the fly likes Close, but no cigar! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Close, but no cigar!" Watch "Close, but no cigar!" New topic
Author

Close, but no cigar!

Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1199
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

Joined: May 17, 2005
Posts: 91
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

Joined: Jul 22, 2000
Posts: 9053
    
  12
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.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1199
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

Joined: Jul 22, 2000
Posts: 9053
    
  12
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

Joined: Mar 15, 2001
Posts: 1199
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

Joined: Jul 04, 2005
Posts: 18
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Close, but no cigar!