Go back to previous page in jsp/servlet
Try the following ways
----------------------------------------------------------------------------------------------------------------->>>>>
<button type="button" name="back" onclick="history.back()">back</button>
<a href="index.jsp">Back</a>
<button type="button"
name="back"
onclick='window.location='<your_path>/index.jsp'>back</button>
-------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>
previous.jsp
............................
<form method="post" action="Student">
<input type="hidden" name="back" value="previous.jsp" />
<input type="text" name="studentname"/>
<input type="submit" value="search"/>
</form>
result.jsp
..................
out.println("<a href=\"" + request.getParameter("back") + "\">Back</a>");
-------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<!DOCTYPE html>
<html>
<head>
<script>
/* The back() method loads the previous URL in the history list.
This is the same as clicking the "Back button" in your browser.
*/
function goBack() {
window.history.back()
}
</script>
</head>
<body>
<button onclick="goBack()">Go Back</button>
<p>Notice that clicking on the Back button here will not result in any action, because there is no previous URL in the history list.</p>
</body>
</html>
Comments
Post a Comment