• 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

Can't read string with quotes around it in my bean method - Please help?????

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JSP where the user enters a string that is then placed within a column of a table of a database using a JDBC connection. I have found that the user can enter a string with quotes around it and it enters the table fine. I can then query that column fine and place all the values of the column into an array that I use in a drop down menu displaying all of them in another JSP. My propblem now is that if I try and take that value that is selected in the drop down menu that has quotes around it (values without quotes work fine) and use that value to place in another JDBC update statement, I get an emptry string.
For example, if I have something like this that appears in my drop down menu, it will not work:
"This is a test"
If I have the same string without quotes there is no problem:
This is a test
I believe it has something to do with the string being read like this when it has quotes around it:
""This is a test""
I am not quite sure how to deal with this problem since the correct value appears in the database table and can be seen in the drop down even with quotes around it. Whenever I try to use that selected string that has quotes around it though by accessing it in my bean method, I get a totally empty string.
If anyone could please make some suggestions on how to solve this I would greatly appreciate it. This is quote urgent, so the sooner you could answer the better.
Thank you VERY much in advance.
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you try escaping the quotes(if present) with a '\'?
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moined
i am also facing same kind of problem, try using prepared Statement if that helps, though i am not sure on that. if prepared statement could parse the the quotes and pass the values properly for the JDBC query..
arpit
 
Moined Mogul
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried escaping them within the bean method but that did not work...
I will look into using a prepared statement for it...could someone give me an example of using a prepared statement for query.....
 
Moined Mogul
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I really do not understand why it works fine for displaying the values with quotes in my drop down menu but when I try to retrieve that selected value from the drop down with quotes around it, I get nothing???
By using the prepared statement, will that automatically get rid of any special characters within the string???
Could someone please clarify this???
 
reply
    Bookmark Topic Watch Topic
  • New Topic