File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Can't read string with quotes around it in my bean method - Please help????? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Can Watch "Can New topic
Author

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

Moined Mogul
Ranch Hand

Joined: Jul 11, 2001
Posts: 33
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.
Sunetra Saha
Ranch Hand

Joined: Feb 25, 2001
Posts: 77
Did you try escaping the quotes(if present) with a '\'?
arpit singla
Ranch Hand

Joined: Jun 18, 2001
Posts: 66
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

Joined: Jul 11, 2001
Posts: 33
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

Joined: Jul 11, 2001
Posts: 33
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???
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't read string with quotes around it in my bean method - Please help?????
 
Similar Threads
retrieve data from database
How do I remove quotes from around string a user inputted in text box?
Session variables in sql statements
dynamically populating dropdown menu with ajax
Removing quotes from selection from drop down menu????