• 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

Issue in getting a proper result in the ResultSet obj

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can you tell me why this is not working


I got agent_val from here : . And when I try to print agent_val by
It give me a Proper value, which is "Leo Joseph"

and the best part is when I write the above query with the static name.......IT WORKS

I dont understand the point, if getParameter is not working then how come it is able to print right value. And if that is not the problem then how come I am able to print correct value through agent_val but the query does not recognize it???

Please Help,
Thanks & Regards,
Saurabh.
[ November 23, 2007: Message edited by: Saurabh Joshi ]
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your first code you are looking for the literal name "agent_val". You probably want to do this:

This is very insecure though, and very open to SQL injection (look it up on Google). This basically means people can execute queries you don't want them to, including dropping your table or database!

You can prevent this by using a PreparedStatement:
 
Saurabh Joshi
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rob,

Thanks for your reply.
I will certianly look into what you have told me
I am getting that value from a drop down box, so is that still very unsecure?

And yes thanks a lot for the update on that line. I know that was a silly mistake.

Please suggest.
Saurabh.
[ November 23, 2007: Message edited by: Saurabh Joshi ]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I am getting that value from a drop down box, so is that still very unsecure?


Yes. It doesn't matter what form control you use. Your form control will just submit a value as text and it is trivial to change that value to something harmful.
 
Saurabh Joshi
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I will remember this.
thanks.
 
Rob Spoor
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If someone just follows your webpages then it should be safe. However, nothing prevents him from using some command line tool or anything and making a request with his own, harmful, request parameters.

If you're using GET, he doesn't even need a command line tool - he can just modify the address in the address bar!
reply
    Bookmark Topic Watch Topic
  • New Topic