This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to send alrt message from servlet to html

 
Kasparov Patel
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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
Bartender
Posts: 2729
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be using a JSP for the view so that you can make decisions about what to show or not.
 
M C Williams
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not familiar with framwork.
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are not familiar with frameworks, then Google for it and get familiar with them. It will make things much easier got you.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic