Meaningless Drivel is fun!*
The moose likes JSP and the fly likes Code checks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Code checks "submit" type button" Watch "Code checks "submit" type button" New topic

Code checks "submit" type button

Ivan Turner
Ranch Hand

Joined: Feb 27, 2012
Posts: 37
The code "if(request.getParameter("post") != null )" and "if(request.getParameter("addBulletin") != null" is testing whether a button was clicked within jsp. How does a button become not null and with what not null value is it populated? I can't find the answer on google.
Ivan Turner
Ranch Hand

Joined: Feb 27, 2012
Posts: 37
A quick out.println("**"+request.getParameter("post")+"**"); indicated that the value attribute of the input tag not only shows as the button's text but it is also the value associated with getParameter. I didn't need google after all!!!
Ashwini Kashyap
Ranch Hand

Joined: Aug 30, 2012
Posts: 90
Hi Ivan,

The approach with which you are checking the click event of the button is absolutely incorrect.
Make use of javascript or JQuery to check events like button clicked and so on.

If you choose javascript then you may make use of onclick() event of button and then invoke its function for the same.

Let me know if you have any further concerns.

Thanks and Regards,
Ashwini Kashyap
I agree. Here's the link:
subject: Code checks "submit" type button
Similar Threads
Request parameter is missing
send values from javascript to servlet
JSP form processing
request.getParameter() returning null
How to perform MultiTask in a Servlet