I have 2 entities - tutor and Subject.
At the controller, I have problem with the code where I need to set the tutor to get the list of subjects which are in String.
Here’s the snippet of code in the servlet:
tutor m4 = new tutor();
String[] subj = request.getParameterValues(“subject”);
Listsubjects = new ArrayList(Arrays.asList(subj));
for(String subject : subjects){ //next() returned showed values
System.out.println(subject);//no explicit return value
// m4.setSubject(subject); //setSubject() returned null
//m4.setSubjlist(subjects);
m4.setSubjs((Subject) subjects);
I have tried various ways to set the subject at the class Tutor without avail.
The error message // shows that the tutor is not reading in the values
Here’s how I did the setter at tutor class
public class tutor{
private String tutorName;
tutor subj;
public tutor setSubject(String subject) {
return this.subj;
}
My question is how do I write the setter in tutor Class in order for the code to work in the Servlet.
I am using Java EE7, 1.8 Java SE and Tomcat.