This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to prevent double data processing on page reload in jsp  RSS feed

Sarvya padwal
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I have written one scriplet tag in jsp.
In that tag, I am calling method on one java that takes Request,response parameters and returns one bean.
But when I reload the page, request.getParameter() gives me same value as before and that leads to double data processing.
How can I prevent this?

===============My main page starts======================
<%@ include file="/jsp/header/mainHeader.jsp"%>
MyClass myClass = MyClass ();
myClass .execute(request,response);
DisplayBean displayBean = myClass .getDisplayBean();
<!-- This html body content depends on displayBean -->
===============My main page ends======================

actually one another jsp page is sending request to this page,
In that page, I am submitting one form which has method="POST"
and that form sends one parameter named "actionName"

as soon as my main page encounters scriplet, it calls execute method
content inside execute method is:
public void execute (HttpServletRequest request, HttpServletResponse response)
String actionName = request.getParameter ("actionName");
DisplayBean displayBean = new DisplayBean();
if (actionName != null && !"".equals (actionName) && "add".equalsIgnoreCase (actionName))
else if (actionName != null && !"".equals (actionName) && "update".equalsIgnoreCase (actionName))



Main Issue is:
when I reload the page, request.getParameter("actionName") returns same string as prevois one(eg: "add")
and this leads to double processing.

Please help me to resolve this issue.
Bear Bibeault
Author and ninkuma
Posts: 66208
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start by following modern best practices. That means no scriptlets in the JSP page, and structuring the controllers correctly.

Please read this article and pay particular attention to the PRG pattern.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!