Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clear a message on page load

 
Sam Saha
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can we say anything without knowing what's putting it there in the first place?
 
Sam Saha
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sam,
Why are you not using any client side scripting language like javascript for this purpose?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would scripting be appropriate?
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic