views:

20

answers:

1

I have this code in my jsp

<div class="controls">
    <input type="image" class="sprite submit-button button" name="SubmitChangeCreds" value="ChangeUIDSubmit" src="../images/layout/transparent.png" />
</div>

In my servlet I am trying to get the value of this image like this

request.getParameter("SubmitChangeCreds")

But this is null.

Help will be much appreciated.

+1  A: 

As per the HTML specification, the input type="image" is to be used as an image map. The webbrowser will send the x and y position of the mouse pointer to the server when the enduser clicks on the image map. The submitted value is available as originalname.x and originalname.y.

So in your case:

String x = request.getParameter("SubmitChangeCreds.x");
String y = request.getParameter("SubmitChangeCreds.y");

However, you seem after all to be abusing the input type="image" since you don't seem to be interested in the mouse position. I'd suggest to just use input type="submit" wherein the image is specified as a CSS background image.

E.g.

<input type="submit" class="sprite submit-button button" name="SubmitChangeCreds" value="ChangeUIDSubmit" />

with e.g.

.submit-button {
    background-image: url('../images/layout/transparent.png');
}

That's a more correct usage of background images in buttons.

BalusC
Thanks BalusC.... Much appreciated
mujeeb