According to Sending additional data with multipart, request.getParameter;
cannot use with enctype="multipart/form-data"
. At process.jsp, I didn't use request.getParameter
. But jsp:getProperty
return null value.
Removing enctype="multipart/form-data"
works fine.
I would like to know how enctype="multipart/form-data" effects jsp:setProperty and jsp:getProperty
. How they are connect? I know jsp:setProperty
is not prefer way.
As I am working with old code, no framework or not MVC is used. But I have to run with servlet 3.0 and tomcat 8.5. Is there any other way to pass data while using enctype="multipart/form-data"
to Jsp to Jsp?
form.jsp
<!-- <form action="process.jsp" method="post" enctype="application/x-www-form-urlencoded"> -->
<!-- <form action="process.jsp" method="post"> -->
<form action="process.jsp" method="post" enctype="multipart/form-data">
Name:<input type="text" name="name"><br>
Password:<input type="password" name="password"><br>
Email:<input type="text" name="email"><br>
File:<input type="file" name="fileName"><br>
<hr>
<input type="submit" value="register">
</form>
process.jsp
<jsp:useBean id="bean" class="dao.User" scope="page">
<jsp:setProperty property="*" name="bean"/>
</jsp:useBean>
Record:<br>
<jsp:getProperty property="name" name="bean"/><br>
<jsp:getProperty property="password" name="bean"/><br>
<jsp:getProperty property="email" name="bean" /><br>
User.java
public class User {
private String name;
private String password;
private String email;
private String fileName;
// getter and setter...
}