how to upload a file and update other fields on the jsp form page at the same time?
Posted on 2004-09-23
I have a jsp form which has a "browse" button and many other fields. THe idea is when user click on "submit", if there is a file entry in the "browse" button text field entry, then the file should be uploaded to the server, and any other changes on the form should also get pass to the database.
I use a ContollerServlet to handle all the request from form, and pass the request to other classes to process the request and finally pass the result to JSP pages.
I have successfully make s the form work without "browse" button. but when the "browse" button is added, the submit failed. my questions are:
1. is it possible to pass the "request" class from JSP to java class? Is the "request" on JSP page same as "HttpServletRequest " in servlet doPost()?
if both request are referring the same thing, why is the parameters on the form could not be passed to the java class, by using
request.getParameter() in the servlet? is it because I have to use the form tag like this one:
<form action="<%=request.getContextPath()%>/servlet/ControlServlet?from=Upload" ENCTYPE="multipart/form-data" method="post" name="visits" onSubmit="return validate()" >
makes all the other parameters unaccessible by request.getParameter()?