| Author |
Clear a message on page load
|
Sam Saha
Ranch Hand
Joined: Jan 23, 2010
Posts: 89
|
|
|
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: 56521
|
|
|
How can we say anything without knowing what's putting it there in the first place?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Sam Saha
Ranch Hand
Joined: Jan 23, 2010
Posts: 89
|
|
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: 175
|
|
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: 56521
|
|
|
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!
|
 |
 |
|
|
subject: Clear a message on page load
|
|
|