• 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

Reverse2Servlet

 
Ranch Hand
Posts: 111
jQuery Oracle C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My code for the servlet in Assignment: Servlets-3 Reverse2Servlet seems to be working except when a single quote gets put into the text box and submitted. When that happens the text that gets reversed and sent back is whatever is after the single quote and I am not sure how or whether I need to correct for this situation.
Any Suggestions?
Amber
 
tumbleweed
Posts: 5089
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Amber slow down youre giving me a complex .
Sorry again I cant help, lets hope the "boss" responds.
 
Amber Woods
Ranch Hand
Posts: 111
jQuery Oracle C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't worry with all the files associated with Servlets 4 and 5 I am sure to slow to a crawl real quick.
Amber
 
Amber Woods
Ranch Hand
Posts: 111
jQuery Oracle C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I feel like I have tried everything to make this Servlet work when a single quote gets entered but I am all out of ideas.
Do I even need to worry about whether they enter the single quote or Not? If so, any suggestions on how to proceed?
Amber
 
Johannes de Jong
tumbleweed
Posts: 5089
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Amber I'll try and look at it this weekend, we have 3 day one
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A servlet will interpret a single quote as a marker for the beginning or the end of the string in the textbox. You need to find a way for the servlet to recognize the single quote as just a single quote and not a marker. (I don't know what the technical word is so I am using the word "marker".)
There is a class in com.javaranch.common.* that has a method that is useful for doing this. If you don't want to use that class, there is a class in the regular Java api that has a method that does the same thing.
 
Amber Woods
Ranch Hand
Posts: 111
jQuery Oracle C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Daniel,
I got it to work with the single quote
But it took me a long time to figure out what to convert the single quote to so the browser could read it correctly.
Amber
 
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe something like this will help:
static String validHTML( String original )
{
int ol = original.length();
StringBuffer new = new StringBuffert( ol );
char next;
for ( int i = 0 ; i < ol ; i++ )
{
next = original.charAt(i);
if ( next == ''' )
{
new.append( "&$#39");
}
else if
" other difficult cases etc."
}
More or less taken from: Professional JSP ...
reply
    Bookmark Topic Watch Topic
  • New Topic