• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Close, but no cigar!

 
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
https://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
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic