0

I am looking to upload a photo with some data to MySQL database, i am able to insert the data but everything I find about uploading a picture uses a servlet. I need jsp code because the page i enter the data in calls another jsp page that does the connection to the database and the insert.

ps: the picture I've chosen through a browse option I have got that part done I just need the jsp code to insert it to the database.

That's where I am adding the picture:

<input type="file" name="photo" size="50"/>
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
user3671619
  • 47
  • 1
  • 1
  • 7
  • 1
    I'm unclear. Are you storing the image in the database or the file server? – Strawberry May 30 '15 at 08:36
  • i want to store the image in MySQL, that's where i am storing the other data inputted with the picture, i am using a jsp page to do the connect and insert for the data and i also want to insert the picture – user3671619 May 30 '15 at 08:56
  • How large (kb) are the images? – Strawberry May 30 '15 at 09:06
  • not greater than 5mb=5120kb – user3671619 May 30 '15 at 09:23
  • Other considerations aside, for images anywhere near that size (in fact, generally for images over 250kb), it's unlikely to be efficient to store the images in the db. Are there other reasons for choosing the db over the file server for storing content? – Strawberry May 30 '15 at 10:17
  • As to that you found only Servlet examples, if you're absolutely positive that you need to put Java code in a JSP file instead of a normal Java class, then there are no technical restrictions to do so. It's only "Terribly Bad Practice". So, just follow the Servlet examples you found for your JSP. – BalusC May 30 '15 at 11:48

0 Answers0