I am validating my html form in servlet. If any valye is missing or malformed my code in servlet should send alert message. Can anyone help me? How can I do?
Thanking You,
Kasparov
Tim Moores
Rancher
Joined: Sep 21, 2011
Posts: 2329
posted
0
What prevents you from displaying an appropriate message in the HTML that is returned in the response? All common web frameworks (Struts, Stripes, JSF, etc.) have this functionality -displaying error messages next to input fields that failed a valiadtion- built in, by the way. You may want to check out some of those frameworks.
Kasparov Patel
Greenhorn
Joined: Jan 23, 2012
Posts: 28
posted
0
I am not getting alert message. Plese check my code given below:
This code sending back to same html page without alert message. Is there anyother way to show message beside corresponding field?
Bear Bibeault
Author and opinionated walrus
Marshal
Your servlet is generating html, so you can't just write a javascript alert statement in the html, you have to also write out a script block just as if you were writing it directly in an html file. Since you are writing the html in the servlet, you can put the notations next to each html field to mark the ones in error as you write them out into the html, and possibly an error message somewhere on the page. How you do that is a style/design choice. At that point, having an actual javascript alert may not be necessary and may be somewhat annoying to occur directly on page load. This is all assuming you are not using one of the frameworks mentioned that have this functionality built-in that you can make use of.
Kasparov Patel
Greenhorn
Joined: Jan 23, 2012
Posts: 28
posted
0
I am not familiar with framwork.
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1503
posted
0
If you are not familiar with frameworks, then Google for it and get familiar with them. It will make things much easier got you.
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Bear Bibeault
Author and opinionated walrus
Marshal
Bosun Bello wrote:If you are not familiar with frameworks, then Google for it and get familiar with them. It will make things much easier got you.
Meh, I'm not much of a cheer-leader for the frameworks. If the OP doesn't know enough yet to be able to send information to a JSP for conditional inclusion on the page, a framework is premature and will just add to the confusion, or, worse, actively prevent him from learning basic servlet and JSP concepts that he needs to know.
subject: How to send alrt message from servlet to html