I have jsp1 where user checks couple of check boxes On jsp2 am successfully able to read the checkbox values using String.
But I also need to created a user object with the parameters selected on jsp1, so that I can write it to a text file. This is where I'm hitting a road block. When independently I ran the code is java console it's working fine. But the actual code isn't. I'm getting below error
An error occurred at line: 29 in the jsp file: /ProcessMyForm.jsp
The constructor User(String, String, String, String, String, String[], String) is undefined
26: String path = sc.getRealPath("/WEB-INF/EmailList.txt");
27:
28: // use regular Java objects
29: User user = new User(userName, emailAddress, password, comment, emailFormat, serverScript, occupation);
30: UserIO.add(user, path);
31: %>
32:
Below is the code where I'm reading the jsp values and trying to create an object
<%
// get parameters from the request
String userName = request.getParameter("userName");
String emailAddress = request.getParameter("emailAddress");
String password = request.getParameter("password");
String comment = request.getParameter("comment");
String emailFormat = request.getParameter("emailFormat");
String serverScript[] = request.getParameterValues("serverScript");
String occupation = request.getParameter("occupation");
ServletContext sc = this.getServletContext();
String path = sc.getRealPath("/WEB-INF/EmailList.txt");
User user = new User(userName, emailAddress, password, comment, emailFormat, serverScript, occupation);
UserIO.add(user, path);
%>
Below is the code for the constructor public class User { private String userName; private String emailAddress; private String password; private String comment; private String emailFormat; private String serverScript[]; private String occupation;
@SuppressWarnings("empty-statement")
public User()
{
userName = "";
password = "";
emailAddress = "";
comment = "";
emailFormat = "";
occupation = "";
}
public User(String userName, String emailAddress, String password, String comment, String emailFormat, String[] serverScript, String occupation)
{
this.userName = userName;
this.emailAddress = emailAddress;
this.password = password;
this.comment = comment;
this.emailFormat = emailFormat;
this.serverScript= serverScript;
this.occupation = occupation;
}
Would you please help me solve the issue. Please let me know if you need additional details