Forums Register Login

How can i avoid replications?

+Pie Number of slices to send: Send
i have this code:
<HTML><HEAD><TITLE>Dynamic Form</TITLE></HEAD>
<BODY>
<%@ page import = "java.sql.*"%>
<%@ page import = "java.sql.SQLException"%>
<%@ page import = "javax.sql.rowset.CachedRowSet"%>
<%@ page import = "java.util.ArrayList"%>
<%@ page import = "com.sun.rowset.CachedRowSetImpl"%>

<CENTER>
<%
String Name = request.getParameter("FillName");
String SubjectS = request.getParameter("subject");
String EmailP = request.getParameter("email");
String Qtype1 = request.getParameter("Question1");
String Qtype2 = request.getParameter("Question2");
String b = request.getParameter("rating");

String connectionURL
= "jdbc:mysql://localhost/createquestions";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
ResultSetMetaData metaData = null;

Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection (connectionURL, "root", "");
statement = connection.createStatement();

//to register the information for the questions generator.
String query = "insert into publishers (publisherName,publisherSubject,publisherEmail) values('"+Name+"','"+SubjectS+"','"+EmailP+"')";
int d=statement.executeUpdate(query);
.
.
.
when i click refresh icon i got same registerd information in my data base i want to avoid this replication.

Oh, if forgot the idea of this code is to resive users and register thier informations in data base allow them to choose type of questions that they want to create them.
[ March 02, 2006: Message edited by: Bear Bibeault ]
+Pie Number of slices to send: Send
You've got all the code in the JSP. So of course, if the page gets refreshed, it's going to keep doing the same thing again and again and again.

Step 1: learn proper web application architecture and get that database code off the page.

Step 2: make sure that when a page is displayed, refreshing it will not cause active operations to repeat. The so-called "PRG Pattern" can help you there.
+Pie Number of slices to send: Send
can you show me how to disable back button and refersh button
+Pie Number of slices to send: Send
You cannot reliably disable the back and refresh actions.

Besides, that would just be a band-aid approach to the problem. What you really need to do is to fix your application.

An older article on the PRG pattern (which stands for Post-Redirect-Get) can be found here.
Water proof donuts! Eat them while reading this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 919 times.
Similar Threads
How to store option format value in database in jsp
need help. I have problems running the client
my servlet can't initialize: null
SQL error
Help with servlets
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:13:42.