次のように、request.setAttribute メソッドを使用してオブジェクトをサーベルトに渡そうとしています。
jsp :
<%request.setAttribute(ResponsibilitiesCollectionRdg.RESPONSIBILITIES_COLLECTION, new ResponsibilitiesCollectionRdg());%>
ジャバコード:
public class ResponsabilityHtmlCommand extends FrontCommand {
@Override
public void processRequest(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException
{
int id = new Integer(request.getParameter("ID")); //get the id of the module
boolean toAdd = new Boolean(request.getParameter("toAdd")); // get if we need to add or remove the responsibilities
ResponsibilitiesCollectionRdg respos = (ResponsibilitiesCollectionRdg) request.getAttribute(ResponsibilitiesCollectionRdg.RESPONSIBILITIES_COLLECTION);
//add or remove the responsibilities
if(id != -1)
{
if(toAdd)
respos.addResp(id);
else
respos.removeResp(id);
}
response.getWriter().write(ResponsabilityFinder.findHtmlForRespDropDown(respos.getListOfResp())); //send the tag
}
getAttribute メソッドの後、変数 "respos" に null が含まれています。私の問題を解決する方法はありますか?