Here’s how you can create the success page and failure page, along with the correct query for redirecting in your servlet for transaction processing.
1. HTML Pages
Success Page (success.html)
Success
Transaction Successful
Your transaction has been processed successfully!
Failure Page (failure.html)
Failure
Transaction Failed
There was an error processing your transaction. Please try again later.
2. Redirect Query in Servlet
In your servlet handling the transaction processing, you can use the following logic to redirect based on the transaction outcome.
Example Code in Servlet:
// Assume you have logic to check transaction success
boolean transactionSuccess = // Your transaction logic here
if (transactionSuccess) {
// Redirect to success page
response.sendRedirect("success.html");
} else {
// Redirect to failure page
response.sendRedirect("failure.html");
}
3. How This Works
• If the transaction is successful, the servlet redirects to success.html, displaying the success page.
• If the transaction fails, the servlet redirects to failure.html, displaying the failure page.
• No query string (?status=...) is necessary in this case since you are directly redirecting to static HTML pages.
This approach is clean and straightforward for showing simple success or failure messages.