The Web Application Hacker’s Handbook Discovering and Exploiting Security Flaws


Chapter 9  ■ Injecting Code



Download 5,76 Mb.
Pdf ko'rish
bet520/875
Sana01.01.2022
Hajmi5,76 Mb.
#293004
1   ...   516   517   518   519   520   521   522   523   ...   875
Bog'liq
3794 1008 4334

Chapter 9 



Injecting Code



297

70779c09.qxd:WileyRed  9/14/07  3:13 PM  Page 297




In the second example, the query structure is defined using a question mark

as a placeholder for the user-supplied parameter. The 

prepareStatement

method is invoked to interpret this, and fix the structure of the query that is to

be executed. Only then is the 

setString

method used to specify the actual

value of the parameter. Because the query’s structure has already been fixed,

this value can contain any data at all, without affecting the structure. The

query is then executed safely:

//define the query structure

String queryText = “SELECT ename,sal FROM EMP WHERE ename = ?”;

//prepare the statement through DB connection “con”

stmt = con.prepareStatement(queryText);

//add the user input to variable 1 (at the first ? placeholder)

stmt.setString(1, request.getParameter(“name”));

// execute the query

rs = stmt.executeQuery();



N OT E


Download 5,76 Mb.

Do'stlaringiz bilan baham:
1   ...   516   517   518   519   520   521   522   523   ...   875




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish