I have searched multiple places but couldn't quite find what I need. I am new to servlets and html and pretty sure I am missing something simple.
I have one servlet servletA in it's doGet, I do the following:
response.setContentType("text/html");
PrintWriter out = response.getWriter();
StringBuilder sb = new StringBuilder();
sb.append("<html><head></head><body>");
sb.append("<div><select name=\"thisparameter\">");
ArrayList<A> list = helper.getList();
sb.append("<option value=\"select\">Select an option</option>");
for (int i=0; i<list.size(); i++) {
A a = list.get(i);
sb.append("<option value="+ a.getYear()+">" + a.getName() + "</option>");
}
sb.append("</select>");
sb.append("<form action=\"servletB\" method=\"GET\">\n" +
" <button type=\"submit\">Go</button>\n" +
"</form></div>");
sb.append("</body>");
sb.append("</html>");
out.println(sb.toString());
out.close();
In servletB's doGet()
PrintWriter out = response.getWriter();
StringBuilder sb = ServletHelper.getHeaderHtml();
response.setContentType("text/html");
String thisparameter = request.getParameter("thisparameter");
The string thisparameter is always null. I tried with POST and got the same result. I would really like to use only servlets and not a combination with JSP. Any help would be highly appreciated. Thank you.