I try to pass attributes to a request into a servlet, but somehow it does not seem to work:
try{
request.setAttribute("str","test");
request.setAttribute("compt",compt);
request.setAttribute("raton",raton); //I tried with different types
// request.getParameterMap().size() always evaluate to 0 instead of "the number of arguments"
Map<String, String[]> parameters = request.getParameterMap();
for(String parameter : parameters.keySet()) { //is never looped
String[] values = parameters.get(parameter);
for(String v : values) out.println(v);
}
request.getRequestDispatcher("/index.jsp").forward(request, response);
}
catch(Exception ex){
ex.printStackTrace();
}
And of course consequently, I get no attribute when parsing the request into the JSP. Did I miss something??
Thx in advance
Aucun commentaire:
Enregistrer un commentaire