title: Sequence Generation to expire on JSP page refresh
body: <p>On Registering a new User in JSP, PID is generated automatically by sequence generator(SQL). But the problem occurs is when i refresh the submitted page save.jsp again, the same data is stored again with next value of sequence. How to avoid it?</p>
  
  <h1>save.jsp</h1>
  
  <pre><code>response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
  response.setHeader("Pragma", "no-cache"); //HTTP 1.0
  response.setDateHeader("Expires", 1); //prevents caching at the proxy server
  
  String account = request.getParameter("account");
  String username = request.getParameter("username");
  String password = request.getParameter("password");
  String notes = request.getParameter("notes");
  
  String LoginUser=(String)session.getAttribute("uid");
  passwords a = new passwords();
  
  a.setLoginUser(LoginUser);
  a.setAccount(account);
  a.setUsername(username);
  a.setPassword(password);
  a.setNotes(notes);
  
  
  SessionFactory sf = NewHibernateUtil.getSessionFactory();
  Session s = sf.openSession();
  Transaction tx = s.beginTransaction();
  s.save(a);
  tx.commit();    
  </code></pre>
  
  <h2>passwords.java</h2>
  
  <pre><code>@Entity
  @Table(name = "passwords")
  public class passwords implements Serializable{
  
  @Id
  @SequenceGenerator(name = "B", sequenceName = "PIDSeq", allocationSize = 1)
  @GeneratedValue(generator = "B", strategy = GenerationType.SEQUENCE)
  int PID;
  String LoginUser;
  String username;
  String account;
  String password;
  String notes;'
  </code></pre>