Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

double quotes in java

 
Amod Mulay
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
while passing values from a jsp to a servlet if i am passing a double quote by replacing it with it's ascii value and further pass it through to a query ...obviously the resultant is wrong.....tried to search through SQL help but haven't been able to breake this problem...
EG: Select * from xya table where name="Am""od";

well one of our clients has entries in his database ..... interisting HAN!!!
So does anyone know how i can tackle this problem
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This definitely is not on the SCJP exam, so I'm moving it to the JSP forum.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this really a JSP question ?
Anyway, did you try to use single quotation in your SQL ?
where name='Am""od';
 
Amod Mulay
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well i do not know how to change my forum from SCJP to any other that i want...but deff. this not a jsp question...
and yes i have tried doing that but it does not work that way.......
 
Stefan Evans
Bartender
Posts: 1691
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use prepared statements.

That will escape any nasty characters in the data for you, and you don't have to worry about sql injection attacks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the JDBC forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic