Reputation: 127
servlet1:
I'm trying to pass parameters to another servlet2:
..
out.print("<input type='text' name='someText' src='someSrc' onclick='submit()'/>");
..
clicked it - servlet2 is loading.
servlet2:
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
Enumeration params = request.getParameterNames();
while (params.hasMoreElements())
{
out.print("parameter: " + (String)params.nextElement() + "</br>");
}
}
my output --> someText so far so good!
but when my input type is image my output is empty:
out.print("<input type='image' name='someText' src='someSrc' onclick='submit()'/>");
any suggestions?
Upvotes: 0
Views: 494
Reputation: 14877
As per the HTML specification, the input type="image"
is to be used as an image map. The web browser will send the x and y position of the mouse pointer to the server when the end user clicks on the image map.
out.print("<input type=\'image\' name=\'imgButton\' src=\'flowsheet/images/submit_button.gif\'/>");
The submitted value will be available as imgButton.x
and imgButton.y
But,If you just want to use styled button in your page to submit data. Use input type="submit"
where you can specify CSS background image for button.
Upvotes: 1