The scenario is really that i'm accepting a unicode string from user on web page as well as on click from the submit button the control moves to another page in which the complete logic of processing the string is written utilizing a bean class simultaneously i m placing the string in to the database by providing call to operate of DAO class from the inside bean class in order to keep up with the log.

however , when user refreshes the end result page the bean class gets known as over and over and therefore exactly the same string gets placed in to the database through the same user several occasions.

what must i do so that string placed through the same user will get placed into database only if user presses the submit button not while refreshing the end result page. or must i keep up with the snacks with string as values in the user and appearance it when page will get loaded.

i'm attempting to maintain snacks at client side for that string which was formerly joined through the user and appearance it accordingly

private void fnSetCookieValues(HttpServletRequest request,
                               HttpServletResponse response) {          
  Cookie[] cookies=request.getCookies();
  for (int i = 0; i < cookies.length; i++) {                    
    System.out.println("" + cookies.length + "Name" + cookies[i].getName());
    if(cookies[i].getName().equals("DNString")) {   
      System.out.println("Inside if:: " + cookies[i].getValue() +
                         "" + cookies.length);
    } else {
      Cookie ck = new Cookie("DNString", ";");

This bit of code is designed in servlet which will get known as on submit button click but each processing of the servlet shows 1NameJSESSIONID it's not showing the cookie DNString

Can anybody determine the error i'm doing?

you're considering a method to prevent double-submits? You will find a few approaches, based on your security needs and also the frameworks you're using:

  1. Java Script
  2. Tokens
  3. Synchronization

Google around a little. You will find several solutions available.

Thanks, M

It's not good method of check whether information is already joined or otherwise. So, Among the easy fix for your problem is by using HTTP redirect following the form submission out of your servlet.Let tell success.jsp. Hence the shape isn't posted again.

You may also totally reset your form when you get response.

For More check here