Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Getting null values in database while edit.jsp

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HELLO! I am trying to edtit my database data using jsp. I have already created edit.jsp (which is ok) and update.jsp. The problem is that while i click edit it saves data as null in database.

edit.jsp


update.jsp



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

You only send the id as request parameter,
update.jsp?id=<%=rs.getInt(1)%>

the other parameters have null values since they not are present in the request.
update.jsp?id=<%=rs.getInt(1)%>&email=<%=rs.getString(4)%>
Try this and you gonna get a non null email.


Best regards,

PD: Try a html form better than encode the parameters in the get url.
 
laura xhaferaj
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It works now. Thank you
 
Carles Gasques
Ranch Hand
Posts: 199
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

try to trace your update query and found out if the parameters from edit.jsp reach update.jsp


Some considerations,
- Never concatenate query string use instead a prepared statement.
- Never access data base from view tier.
- Avoid using get and use post http requests.


Best regards,
 
No prison can hold Chairface Chippendale. And on a totally different topic ... my stuff:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic