wood burning stoves 2.0*
The moose likes JSP and the fly likes Clear a message on page load Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Clear a message on page load" Watch "Clear a message on page load" New topic
Author

Clear a message on page load

Sam Saha
Ranch Hand

Joined: Jan 23, 2010
Posts: 104
I am creating a confirmation message when a form is being submitted successfully. Now when I refreash the page that confirmation message does not go away. Is there any way I can remove that message when the page refresh. Thanks!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60802
    
  65

How can we say anything without knowing what's putting it there in the first place?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sam Saha
Ranch Hand

Joined: Jan 23, 2010
Posts: 104
Here I am doing a form submission from a JSP. When the form submits I am calling a servlet from the form and in that servlet I am setting a attribute using setAttribute() for that message. Using request
.getRequestDispatcher I am coming to the JSP again. Now using getAttribute() I am populating that message. Now when I refresh the page I want this message removed.


This is the code for the Form:

<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>
<div id="message"></div>
<ul class="buttons">
<li class="secondary">
<input type="submit" value="Submit Feedback" />
</li>
</ul>
<% if(request.getAttribute("confMessage") != null){
System.out.println("The value of confmessage is: " + request.getAttribute("confMessage")); %>
<table>
<tr>
<td><%= request.getAttribute("confMessage") %></td>
</tr>
</table>
<% } %>

</form>
Ankit Tripathi
Ranch Hand

Joined: Oct 17, 2009
Posts: 198
Hi Sam,
Why are you not using any client side scripting language like javascript for this purpose?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60802
    
  65

Why would scripting be appropriate?
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

If it is at request scope that means that you are setting it on every request and when you press refresh it is another request.
You will need to have some logic in your servlet that sets it only when it is appropriate.

Sean


I love this place!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Clear a message on page load
 
Similar Threads
Displaying confirmation window using servlets
Page Viewed Notification !
forwarding to an outside URL
ignore exception when cannot connect to smtp server
bookmark a page