This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
Don't get me started about those stupid light bulbs.
subject: Code checks "submit" type button
Similar Threads
request.getParameter() returning null
How to perform MultiTask in a Servlet
Request parameter is missing
JSP form processing
send values from javascript to servlet