I have 2 jsp pages and one Servlet
. I am fetching data from database by servlet and sending result to result.jsp
page where i am displaying result. But i want to add a Back button
in result.jsp
, by clicking back button
i want to go to index.jsp
, but problem is when i am clicking back button everytime a message is coming Confirm form submission
and it is irritating me. How can i avoid this Confirm form submission
? perhaps it is coming as processing is done in servlet.
index.jsp
<form method="post" action="Student">
<input type="text" name="studentname"/>
<input type="submit" value="search"/>
</form>
Student servlet
String student_name=request.getParameter("studentname");
-------fetching data from database------------
-------------------sending to result.jsp------
String nextJSP = "/result.jsp";
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
dispatcher.forward(request,response);
result.jsp
//displaying data here
<form action="index.jsp">
<input type="submit" value="back"/>// a back button is here which is going to index.jsp
</form>
EDIT
From result.jsp
i am going to another page result1.jsp
like below
In result.jsp
i have written the following:
<a href="result1.jsp.jsp?a code=<%out.println(student_name);%>"><%out.println(student_name);%></a>
By clicking the above hyperlink i went to result1.jsp
I want to add a back button here(in result1.jsp) and after clicking i want to do to result.jsp, but when clicking back button i am getting Confirm form submission
every time. I have written the following in result1.jsp
<input type="button" value="Back" onclick="javascript:history.go(-1)">
Still i am getting that message Confirm form submission
. How can i avoid this? I want to go to result.jsp
directly with out this message. How is it possible?
Basically we can call the redirect pages using sendRedirect() method in the jsp on client-side request can be used within the server or outside of the server.
Jsp Back Button enables the user back to the page from which they just come from. INPUT type="button" value="Back" onclick()="history.
To forward a request from one page to another JSP page we can use the <jsp:forward> action. This action has a page attribute where we can specify the target page of the forward action. If we want to pass parameter to another page we can include a <jsp:param> in the forward action.
you can also use this to go one page back
<button type="button" name="back" onclick="history.back()">back</button>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With