java - Passing value to servlet from image -
from jsp have
.. <form action="testmartcontroller" method="post"> <input type="hidden" value="math"> <input type="image" src="<%=request.getcontextpath()%>/css/categories/math.jpg"> </form> ..
in servlet have
... private static final string math = "web-inf/jsp/math.jsp"; protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { string forward = null; string action=request.getparameter("action"); if(action.equals("math")){ forward = math; flag = 1; } requestdispatcher rd = request.getrequestdispatcher(forward); rd.forward(request, response); } ...
when clicked image got null pointer exception. want know why not pass value should. since hidden values pass.
your input type="hidden"
field missing name="action"
attribute. thus, action parameter null.
Comments
Post a Comment