This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, need some help here, i have a program where a user can input name, city and upload image. when a user click the submit button the name, city and the image(Save as BLOB) must be save in the database. and the image will also save in the desired folder. i have no problem in saving the image in the folder, my problem is it can't save the record to mysql database.
heres my code...
Joined: Apr 03, 2012
but when i try to input the record manually to the code like this it will successfully save... see difference in line 53-54(code at the top) from 51-52(here) and i remove some code in line 39-40
And what are the symptoms of your problem? It appears from what you wrote that the record is not being written to the database, but that isn't very helpful. Especially when you have debugging code in place already, which you aren't telling us about.
Joined: Apr 03, 2012
Hi Bear Bibeault,
i put my code into servlet,
upload.jsp to upload.java
can you please check if its correct, and after this, what should be my next step?
To me it looks like you're processing a multipart request with that code. I've done that, but I never considered trying to parse the request myself. Instead, I used the Apache FileUpload package which works just fine and I don't have to hack around with boundaries or any of that. And it can store the file upload in a temporary file if you ask it to do so.
Anyway, one feature of multipart request is that what you think of as "parameters" (i.e. the HTML form fields which aren't file uploads) are not treated as request parameters. One of your code samples appeared to be assuming that they were. But they aren't. They are just another "part" of the request (or maybe one part per parameter, I don't know) so you're going to have to extract them from the request in just the same way as you extracted the file upload.