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 Servlets and the fly likes Need help to display a confirmation message after the form submission 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 » Servlets
Bookmark "Need help to display a confirmation message after the form submission" Watch "Need help to display a confirmation message after the form submission" New topic
Author

Need help to display a confirmation message after the form submission

Sam Saha
Ranch Hand

Joined: Jan 23, 2010
Posts: 104
I am submitting a form. I am calling a servlet for from submission. If the form submission is successful I want to show up a confirmation message in the form itself. Can someone help me how to do that.

This is the code of my form in jsp:

<form name="feedbackForm" action="feedback" method="post">
<input type="hidden" id ="uRecid" name="userRecID" value="<%= request.getSession().getAttribute("USERRECID") %>" />
<input type="hidden" id ="appType" name="applicationType" value="AME" />
<input type="hidden" id ="fromFForm" name="fromFeedbackForm" value="Y" />
<div id="messageText">
<textarea id="feedbackText" name="message" rows="5" cols="70" class="dim" onkeypress="return imposeMaxLength(this, 3999);" onclick="javascript:changeClass(this.className, this.id);">The more specific your question or comment, the better service we can provide.</textarea>
</div>
<script>
$(document).ready(function(){
$('form[name=feedbackForm] input[type=submit]').click(function(e){
e.preventDefault();
$('form[name=feedbackForm]')[0].submit();
$('#feedbackText').val('');
});
});
</script>
<div id="message"></div>
<ul class="buttons">
<li class="secondary">
<input type="submit" value="Submit Feedback" />
</li>
</ul>
</form>
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 507

you can use AJAX..


Regards, Prasad
SCJP 5 (93%)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Prasad Krishnegowda wrote:you can use AJAX..

Ajax would be completely unnecessary and a poor way to handle things. Simple JSP can be used (and based upon another post that is exactly what was done).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sunny Bhandari
Ranch Hand

Joined: Dec 06, 2010
Posts: 448

That is very simple if you capture the onSubmit javascript even and show an alert message or unhide a div tag or use third party attractive messages...


Java Experience
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help to display a confirmation message after the form submission
 
Similar Threads
Can't get to the bean methods
JSP <a href> tags breaks page functionality
Confusing jquery code
Clear a message on page load
set values in a table from other