Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Fileupload with JSP/Servlet

 
Kay Tracid
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to upload a file to my database as blob. i have a servlet doing this, but how can i pass the file(path) from my <form> in my jsp to the servlet? Sorry a simple question...

thx a lot
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at http://jakarta.apache.org/commons/fileupload.
It's a well used upload library and comes with documentation and examples.
 
Kay Tracid
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thx i also find something:


<FORM ENCTYPE='multipart/form-data'
method='POST' action='/myservlet'>
<INPUT TYPE='file' NAME='mptest'>
<INPUT TYPE='submit' VALUE='upload'>
</FORM>

@

http://www.jguru.com/faq/view.jsp?EID=160
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kay Tracid:
thx i also find something:


<FORM ENCTYPE='multipart/form-data'
method='POST' action='/myservlet'>
<INPUT TYPE='file' NAME='mptest'>
<INPUT TYPE='submit' VALUE='upload'>
</FORM>

@

http://www.jguru.com/faq/view.jsp?EID=160


Yes, that is what your HTML forms will need to look like.
You will also need some libraries to handle the multipart data on the server. The link I gave you will provide just such a set of libraries.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic